range « byte « Java Data Type Q&A





1. Why is the range of bytes -128 to 127 in Java?    stackoverflow.com

OK, this is as noob as it gets, but I still don't get why the lowest value a byte can take is -128. That the highest value is 127 I can ...

2. byte and short data types in Java can accept the value outside the range by explicit cast. The higher data types however can not. Why?    stackoverflow.com

Let's consider the following expressions in Java.

byte a = 32;
byte b = (byte) 250;
int i = a + b;
This is valid in Java even though the expression byte b = (byte) ...

3. Range of byte    coderanch.com

numbers are represented by bit patterns. a bit can be '0' or '1'. Each bit added to the storage space doubles the total possible values. So lets assume we only had one bit to store values. you could store two total. zero is usually one, and so that leaves one other value of -1. Now assume we have 2 bits, which ...

4. pls help in understanding the range of byte    java-forums.org

the range of byte according to book is -128 to 127. The binary representation of -128 is 110,000,000 which is 9 bits so how it can be stored in a byte. When I convert -128 to its binary form and print it to console the output is 10,000,000 that is 0x80 in hex. But the compiler gives an error when I ...