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.

Table G.1. Number Systems
Decimal (base 10)Binary (base 2)Octal (base 8)Hexadecimal (base 16)
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012a
11101113b
12110014c
13110115d
14111016e
15111117f
16100002010

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.