Click on the picture to see the hexidecimal numbers for each pixel.

Introduction to binary and hexidecimal numbers

A computer in its most basic sense is a large number of electronic switches, each of which can be in one of two states: on or off. These on-off patterns are used to encode numbers using the binary number system, a method of storing ordinary numbers such as 25 or 180 as columns of 1’s and 0’s — 1 as on and 0 as off. Computers circuits add, subtract, multiply and divide, and do other computations with numbers stored in binary form.

How Binary Works

Decimal Binary
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010

The decimal system we use every day contains 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. When we run out of digits, we add a column worth 10 times the value of the first column. Now we count 10, 11, 12, 13, 14, 15, 16, 17, 18, 19. At 20, the right column goes back to zero, and we begin again: 21, 22, 23 … 94, 95, 96, 97, 98, 99. Now we add a third column worth 10 times as much as the one to its right: 100. Because each column is worth 10 times that of the right, decimal numbers are also called base-10 numbers.

The binary system works in the same way, except it uses only two digits, 0 and 1. Each column is worth two times that of the right, so binary numbers also are called base-2 numbers. Counting in binary goes like this: 0, 1, 10 (2), 11 (3) 100 (4). Watch the pattern of 1’s and 0’s in the table to the left. You will see that binary works the same way decimal does, but with only two digits, 1 and 0.

A bit is a contraction for binary digit. Each binary column represents one bit, 0 or 1. Using bits, we can quickly reach large numbers. Each column after the first represents 2n: 2, 4, 8, 16, 32, 64, 128, 256 and so on.

A byte is eight digital columns representing 255 decimal numbers plus zero (28).

To convert a number from binary to decimal, write it in expanded notation. For example, the binary number 101101 can be rewritten as (1 × 32) + (0 × 16) + (1 × 8) + (1 × 4) + (0 × 2) + (1 × 1) = 45.

What Are Hexadecimal Numbers?

Binary numbers work with computers because the system matches the nature of digital electronics. But binary numbers are inefficient for people because because so many digits are needed to represent a number. The number 84 takes two digits to write in decimal but seven digits to write in binary (1010100).

But a computer can be programmed to work in any base system. While decimal numbers are efficient, we can compress data by converting the binary numbers to hexadecimal numbers, with a base of 16. In hexidecimal numbers, each column is 16 times that to the right.

Hexadecimal works in the same way as binary and decimal, but it uses sixteen digits instead of two or 10. Along with the 10 decimal digits, hexadecimal uses the letters A through F to represent the digits 10 through 15. This chart presents hexadecimal numbers and their equivalents in binary and decimal:

Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F 10
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 10000

Hex-binary-decimal calculator


DECIMAL

HEXIDECIMAL

BINARY

So 20 hexidecimal equals 32 decimal and 100000 binary.

Try to relate the pattern of numbers to how we count in a decimal system. It works the same way but with 16 digits instead of 10.

Because 2 × 2 × 2 × 2 = 16, each hexadecimal digit is worth exactly four binary digits.

Try out this hex-binary-decimal calculator.