G.1. Number Systems
Binary, Octal, and Hexadecimal Number System
Table G.1 lists the integers from 0 to 16, showing their equivalents in the binary (base 2), octal (base 8), and hexadecimal (base 16) number systems. The shaded cells in each column show the digits in each number system.
Decimal (base 10) | Binary (base 2) | Octal (base 8) | Hexadecimal (base 16) |
---|---|---|---|
0 | 0 | 0 | 0 |
1 | 1 | 1 | 1 |
2 | 10 | 2 | 2 |
3 | 11 | 3 | 3 |
4 | 100 | 4 | 4 |
5 | 101 | 5 | 5 |
6 | 110 | 6 | 6 |
7 | 111 | 7 | 7 |
8 | 1000 | 10 | 8 |
9 | 1001 | 11 | 9 |
10 | 1010 | 12 | a |
11 | 1011 | 13 | b |
12 | 1100 | 14 | c |
13 | 1101 | 15 | d |
14 | 1110 | 16 | e |
15 | 1111 | 17 | f |
16 | 10000 | 20 | 10 |
In addition to the decimal literals, Java also allows integer literals to be specified in octal and hexadecimal number systems, but not in the binary number system. Octal and hexadecimal numbers are specified with 0 and 0x prefix, respectively. The ...
Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.