Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Signed Integers Unsigned binary numbers work for natural numbers, but many ca

ID: 3753027 • Letter: 2

Question

2. Signed Integers Unsigned binary numbers work for natural numbers, but many calculations use negative numbers as well. To deal with this, a number of different schemes have been used to represent signed numbers, but we will focus on two's complement, as it is the standard solution for representing signed integers. 2.1 Two's complement Most significant bit has a negative value, all others are positive. So, the value of an n-digit two's complement number can be written as: complement number can be writen as: 21d, 2dn -0204-2n-ldn .Otherwise exactly the same as unsigned integers. . A neat trick for flipping the sign of a two's complement number: flip all the bits and add 1.

Explanation / Answer

Exercise 2.2 Here we are considering 8 bit integer. 1- Largest Number of 8 bit must be of 1's in all of its 8 bits. Let, X be the largest number of 8 bit. Such that, X = 1111 1111. Which is equivalent to 255 in binary. Hence, adding 1 to X result into overflow because it bits increases to 9. Making all of right 8 bits zero and the left most bit equal to 1. Thus, it becomes - 1 0000 0000. But we have to consider for only 8 bits. Therefor it will ignore the leftmost bit or carry bit and results it into 0000 0000. 2. Decimal to binary representation. (0)decimal = (0000 0000)binary (3)decimal = (0000 0011)binary (-3)decimal = (1111 1101)binary, 2's compliment of 3 3. (42)decimal = (0010 1010)binary (-42)decimal = (1101 0110)binary, 2's compliment of 42 4. Largest number of any encoding that can be represented by 8 bits consist of 1 in all 8 bits. (1111 1111)binary = (255)decimal for unsigned number. Range for unsigned: 0 ... 255 (1111 1111)binary = (127)decimal for signed number. Range for signed: -128 ... 127 Refer question 1 for more details. 5. Two's compliment inversion trick. Proof: Let, X = 0000 0101 decimal equivalent 5 So, X' = 1111 1010 compliment of X with all bits reversed 0000 0101 + 1111 1010 ----------------- 1111 1111 ----------------- Adding 1 again to result 1111 1111 + 1 ----------------- 1 0000 0000 ----------------- But, we have to consider only 8 bits. Neglecting the left most bit we get (0000 0000)binary = (0)decimal Thus, we can say that X + X' + 1 = 0. Proved. Note: For any query drop comment.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote