CPE 323 Data Types and Number Representations
Aleksandar Milenkovic
Numeral Systems: Decimal, binary, hexadecimal, and octal
We ordinarily represent numbers using decimal numeral system that has 10 as its base
(also base-10 or denary). The decimal numeral system uses 10 symbols: 0, 1, 2, 3, 4, 5, 6,
7, 8, and 9. It is the most widely used numeral system, perhaps because humans have ten
fingers over both hands.
For example, a decimal number 456 could also be represented as (4 100’s, 5 10’s, and 6
1’s):
456
10
= 4*10
2
+ 5*10
1
+ 6*10
0
The binary numeral system, or base-2 (radix-2) number system, is a numeral system that
represents numeric values using only two symbols, 0 and 1. These symbols can be
directly implemented using logic gates and that is why all modern computers internally
use the binary system to store information.
For example, 10111
2
is a binary number with 5 binary digits.
The left-most bit is known
as the most significant bit (msb), and the rightmost one is known as the least-significant
bit (lsb). This binary number 10111
2
can be converted to a corresponding decimal
number as follows:
10101
2
= 1*2
4
+ 0*2
3
+ 1*2
2
+ 1*2
1
+ 1*2
0
= 23
10
Hexadecimal (base-16, hexa, or hex) is a numeral system with a radix, or base, of 16. It
uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to
nine, and A, B, C, D, E, F (or a through f) to represent values ten to fifteen.
For example, a hex number 1A3
16
corresponds to
1A3
16
= 1*16
2
+ 10*16
1
+ 3*16
0
= 256 + 160 + 3 = 419
10
1A3
16
= 1_1010_0011
2
Its primary use is as a human friendly representation of binary coded values, so it is often
used in digital electronics and computer engineering. Since each hexadecimal digit
represents four binary digits (bits), it is a compact and easily translated shorthand to
express values in base two.
Octal (also base-8) is a number system with a radix, or base, of 8. It uses 8 distinct
symbols 0, 1, 2, 3, 4, 5, 6, and 7.
An octal number 372
8
corresponds to