Java Datatypes like int
,short
,byte
are two's complement integers ,as they menioned it in here . what information does it give when someone says that in java , int
,short
or byte
are two's complement integers ?
Update : i wanted to know why 2's complement is prefered over other representations ?
it tells you how signed values (+/-) are represented in binary form.
for example
24 in simple binary form is 00011000
--> 11101000 is the two's complement for -24
that's why (as an example) in java the range of a byte-value is -128 ... 127 all values having a '1' in the 2^7 position are negative.