Originally posted by Charlie James:
Java integers can have three representations, base-8 (octal), base-10, and base-16 (hexadecimal)? I am guessing this is short, int, and long. Am I close ?
It's a good guess, but you're mixing two different concepts.
Ultimately, everything is stored as bits (zeros and ones). In Java, byte, short, int, and long are primitive
types for storing integral values. These types are distinguished by the number of
bits they can hold (8, 16, 32, and 64 respectively).
Different base representations (decimal, octal, and hexadecimal) are available to the Java programmer as different ways to express integral values.
Octal (base 8) literals are prefixed with zero. For example, 034 is an octal representation of 28. Hexadecimal (base 16) literals are prefixed with zero and the letter x, using letters a-f to represent 10-15. (The letters are not case sensitive.) For example, 0x1c is a hexadecimal representation of 28.