For a non negative value, the most significant bit is 0 and the remaining 15 bits represent the value directly.
For a negative value, the most significant bit is 1 and the remaining 15 bits represent the absolute value minus one complemented.
Example for -1:
00000000 00000001 (absolute value) 00000000 00000000 (minus one) 11111111 11111111 (complemented) --> (-1 in 2's complement)
2's complement does not makes sense for unsigned numbers.
For 16 bit unsigned:
Min: 0x0000 --> 0
Max: 0xFFFF --> 65535
For 16 bit signed:
Min: 0x8000 --> -32768
Max: 0x7FFF --> 32767
2's complement is used because it simplifies sums at binary level.
Take these examples:
00000000 00001010 (10 decimal) +11111111 11111001 (-7 decimal) ------------------- 1 00000000 00000011 (3 decimal) (the leftmost 1 is discarded because overflows the 16 bit sum) 00000000 00001100 (12 decimal) +11111111 11101001 (-23 decimal) ------------------- 11111111 11110101 (-11 decimal)
manpreet
Best Answer
2 years ago
This is a computer architecture question given in our college syllabus and i was finding difficulty in solving it. Calculate the range of a 16-bit 2's complement number system for representing both signed and unsigned integers. Please guide me.