Primitive Types Cheatsheet

suggest change

Table showing the size and value range of all primitive types:

data type numeric representation range of values default value
boolean n/a false and true false
byte 8-bit signed -27 to 27 - 1 (-128 to +127) 0
short 16-bit signed -215 to 215 - 1 (-32,768 to +32,767) 0
int 32-bit signed -231 to 231 - 1 (-2,147,483,648 to +2,147,483,647) 0
long 64-bit signed -263 to 263 - 1 (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807) 0L
float 32-bit floating point 1.401298464e-45 to 3.402823466e+38 (positive or negative) 0.0F
double 64-bit floating point 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative) 0.0D
char 16-bit unsigned 0 to 216 - 1 (0 to 65,535) 0

Notes:

  1. The Java Language Specification mandates that signed integral types (byte through long) use binary two's-complement representation, and the floating-point types use standard IEEE 754 binary floating-point representations.
  2. Java 8 and later provide methods to perform unsigned arithmetic operations on int and long. While these methods allow a program to treat values of the respective types as unsigned, the types remain signed types.
  3. The smallest floating-point values shown above are subnormal; i.e. they have less precision than a normal value. The smallest normal numbers are 1.175494351e−38 and 2.2250738585072014e−308.
  4. A char conventionally represents a Unicode / UTF-16 code unit.
  5. Although a boolean contains just one bit of information, its size in memory varies depending on the Java Virtual Machine implementation (see boolean type).

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents