Two's complement represents signed integers in binary: negative values use complemented magnitude bits plus one. It gives fixed-width integers a sign bit and makes overflow wrap from one extreme to the other. section 5.1 section 3.2.3
The representation determines several practical behaviors:
- Arithmetic right shifts preserve the sign bit, padding negative values with ones; unsigned right shifts pad with zeros. section 3.2.3
Inspecting a negative shift
Integer/toBinaryString displays -147 as "11111111111111111111111101101101". Shifting it right by one produces "11111111111111111111111110110110", while shifting by two produces "11111111111111111111111111011011". The leading ones preserve the negative sign.



