Quote:
Originally Posted by ehha
Both signed and unsigned should hold the same amount of numbers, in you example, signed holds 2x.
|
Wow. You are so wrong with your math, but the logic is right.
Quote:
For n-bit signed integers, it is -(2^(n-1)) to (2^(n-1)-1).
For n-bit unsigned integers, it is 0 to (2^n-1).
|
For example, if n = 8 for 8bit integers.
signed = -(2^(8-1)) to (2^(8-1)-1) = -(2^7) to (2^7-1) = -128 to 127
unsigned = 0 to (2^8-1) = 0 to 255
127 - (-128) = 127 + 128 = 255
255 - 0 = 255
__________________