Values of Java integral types occupy different amounts of memory:
- byte: 8 bit
- char: 16 bit
- short: 16 bit
- int: 32 bit
- long: 64 bit
All of them, except char, are signed integer. The sign value (0 for minus "-" and 1 for plus "+") occupies the first bit of the binary representation of the value. That is why a signed integer can hold, as a positive number, only half of the value an unsigned integer can. But it allows a signed integer to hold a negative number, which an unsigned integer cannot do. For example, in case of the byte type (8 bit), if it were an unsigned integer, the range of the values it could hold would be from 0 to 255 (including 0 and 255) because 2 to the power of 8 is 256. But, as we have said, the byte type ...