In the 32-bit version, the representable range is calculated by considering a sign bit, a 23-bit mantissa, and an 8-bit exponent with values between -126 and 127.
Furthermore, the standard provides for the representation of two values for zero (from right to left) two for infinity (positive and negative), and NaN (not a number) values to be used, for example, as results of impossible operations (e.g., divisions by zero).
| Type | Memory Quantity | Represented Information | Default Value |
|---|---|---|---|
| byte | 8 bit | Variable with sign (with "two's complement" representation, two's complement) and represents values in a range [-128 to 127] (inclusive) | 0 |
| short | 16 bit | Signed integers in a range [-32,768, 32,767] | 0 |
| int | 32 bit | Integers (by default signed, signed) in a range [-231, 231-1]. With Java 8, the possibility of using integers to represent unsigned quantities was introduced, which can have a range [0, 232-1] (thanks to specific static methods introduced in the Integer and Long classes) | 0 |
| long | 64 bit | Integers (by default signed, signed) in a range [-263, 263-1]. As with integers in Java 8, there is the possibility of using them as unsigned quantities with a range (positive) that reaches up to 264-1. | 0L |
| float | 32 bit | Single-precision floating-point numbers according to the IEEE 754 specification, using sign, mantissa, and exponent representation.(-1)sign * mantissa * 2exponent | 0.0f |
| double | 64 bit | Double-precision floating-point numbers according to the IEEE 754 specification. The precision with which numbers are represented increases due to the increase in the number of bits used. | 0.0d |
| boolean | not specified, but a single bit would be sufficient | serves to represent only 2 values: true or false (true or false). | false |
| char | 16 bit | Used for storing characters from the Unicode character set) in the range [' ', ''] (in hexadecimal) or equivalently [0,65535]. | |