3 ms·
> (Even if the first bit were interpreted as the sign, shouldn't this be -2,147,483,642?) No, in two-complement (U2) encoding, negative numbers "start from the
by pzmarzly 3y ago
> (Even if the first bit were interpreted as the sign, shouldn't this be -2,147,483,642?)
No, in two-complement (U2) encoding, negative numbers "start from the top". This lets CPUs have same addition and subtraction instructions for signed and unsigned integers, and rely on overflows to get correct value. E.g. (-1)_i8 + 2_i8 = b11111111 + b00000010 = b(1)00000001 = 1
- gushogg-blake 3y agoAh yes that makes sense. Always assumed the sign bit was just a flag.