Question

2. On the Arduino Uno (and other ATMega based boards) an “int” stores a 16-bit (2-byte)...

2. On the Arduino Uno (and other ATMega based boards) an “int” stores a 16-bit (2-byte) value. “int” store negative numbers with a technique called 2's complement math. The highest bit, sometimes referred to as the "sign" bit, flags the number as a negative number. The rest of the bits are inverted and 1 is added. The Arduino takes care of dealing with negative numbers for you, so that arithmetic operations work transparently in the expected manner.

a-What is the range of binary integers that can be stored on the Arduino Uno? What are the corresponding ranges in decimal and hexadecimal notation?

b-How is -128 stored in Arduino Uno using the 2’s complement notation?

Homework Answers

Answer #1

a. Binary integers can be in the range of -2?15 i.e. (1000000000000000)?2 to +(215? - 1) i.e (0111111111111111)?2. Hence in decimal it turns out to be -32768 to +32767. In Hex directly read binary value in group of 4 from LSB direction i.e. 0x8000

b. First represent +128 in binary form and then take 2s complement along with sign bit as 1 to represent negative number.

Hence +128 = (010000000)2? , and its two's complent will be 101111111 + 1 = 110000000

Now Sign extend to have 16 bit number for Arduino Uno Compatability. So -128 = (1111111110000000)?2

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Question 2: The Arduino UNO micro-controller measures 4.25V on its 10-bit 0 − 5V analog-to-digital converter...
Question 2: The Arduino UNO micro-controller measures 4.25V on its 10-bit 0 − 5V analog-to-digital converter (ADC) (a) What is the output of the ADC in decimal and binary? (b) If this digital number is converted to analog using an 8-bit 0 − 5V digital-to-analog converter (DAC). What will be the output of the DAC? What will be the error associated with it?
Consider the number below, which is stored inside a computer which uses 16-bit 2’s complement base...
Consider the number below, which is stored inside a computer which uses 16-bit 2’s complement base 2 representation. 1101011001110101 (a) Is this number negative? Why, or why not? (b) Show the resulting value (“bit pattern”) after apply the 2’s complement negation operation to the given value. Is the resulting 2’s complement value (“bit pattern”) a negative number? Explain your answer.
Assume a computer is using signed magnitude base 2 representation to store 8-bit values. Further, assume...
Assume a computer is using signed magnitude base 2 representation to store 8-bit values. Further, assume you have a program which can display the contents of 1-byte memory locations. However, the program displays hex (as a shorthand) instead of binary. What decimal values are represented by the following: (a) C3 (b) 6E Repeat the above, but assume the numbers are stored as 8-bit 2’s complement base 2.
Adder Start out by picking 2 positive six bit binary numbers that are less than 3210,...
Adder Start out by picking 2 positive six bit binary numbers that are less than 3210, written in 2's complement notation. The eventual goal is to add these two numbers. 1) Look at the LSB bit of the numbers, and using logic gates (NANDs, NORs, etc.) design a circuit that correctly gives the right output for any possible combination of bits in the LSB place. 2) Now look at the next column to the left (next to LSB). In this...
Sign extension means that any given signed number can be represented with more bits by simply...
Sign extension means that any given signed number can be represented with more bits by simply repeating the sign bit. For example, 0005 = +5 and 00005 = +5. This holds true for negative numbers as well. For example, 1011 = -5 and 11011 = -5. Also, 11111011 = -5. Using finite summation notation, prove that sign extension can be applied to any 2's complement binary integer, B, with b number of bits