| Author |
last bit in data type
|
nada saif
Greenhorn
Joined: Nov 14, 2009
Posts: 8
|
|
Hi ,
I am confused about how to define the limits of data in examples we say byte starts from -128 and stops at 127
How we can use -128 as i know the last bit is just for sign ???
Best,
Nada
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
The representation is not as simple as 7 bits for the value and one bit for the sign (independently). There is one bit for the sign, but the eight bits needs to be evaluated together to get the overall value.
Basically, Java uses two complement to represent bytes, shorts, ints, and longs.
http://en.wikipedia.org/wiki/Two's_complement
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: last bit in data type
|
|
|