Binary and hexadecimal numbers are two alternatives to the traditional decimal numbers we use in daily life. Critical elements of computer networks like addresses, masks, and keys all involve binary or hexadecimal numbers. Understanding how such binary and hexadecimal numbers work is essential in building, troubleshooting, and programming any network.

### Bits and Bytes

This article series assumes a basic understanding of computer bits and bytes. Binary and hexadecimal numbers are the natural mathematical way to work with the data stored in bits and bytes.

### Binary Numbers and Base Two

Binary numbers all consist of combinations of the two digits '0' and '1'. These are some examples of binary numbers:**11010101111101111000000 10101000 00001100 01011101**

Engineers and mathematicians call the binary numbering system a *base-two* system because binary numbers only contain the two digits '0' and '1'. By comparison, our normal decimal number system is a *base-ten* system that uses the ten digits '0' through '9'. Hexadecimal numbers are a *base-sixteen* system.

### Converting From Binary to Decimal Numbers

All binary numbers have equivalent decimal representations and vice versa. To convert binary and decimal numbers manually, you must apply the mathematical concept of *positional values*.

The positional value concept is simple: With both binary and decimal numbers, the actual value of each digit depends on its position ("how far to the left") within the number.

For example, in the decimal number **124**, the digit '4' represents the value "four," but the digit '2' represents the value "twenty," not "two." The '2' represents a larger value than the '4' in this case because it is positioned further to the left in the number.

Likewise in the binary number **1111011**, the rightmost '1' represents the value "one," but the leftmost '1' represents a much higher value ("sixty-four" in this case).

In mathematics, the base of the numbering system determines how much to value digits by position. For base-ten decimal numbers, multiply each digit on the left by a progressive factor of 10 to calculate its value. For base-two binary numbers, multiply each digit on the left by a progressive factor of 2. Calculations always work from right to left.

In the above example, the decimal number **123** works out to:

**3 + (10 * 2) + (10*10 * 1) = 123**

and the binary number 1111011 converts to decimal as:

**1 + (2 * 1) + (2*2 * 0) + (4*2 * 1) + (8*2 * 1)+ (16*2 * 1) + (32*2 * 1) = 123**

Therefore, the binary number 1111011 is equal to the decimal number 123.

### Converting From Decimal to Binary Numbers

To convert numbers in the opposite direction, from decimal to binary, requires successive division rather than progressive multiplication.

To manually convert from a decimal to a binary number, start with the decimal number and begin dividing by the binary number base (base "two"). For each step the division results in a remainder of 1, use '1' in that position of the binary number. When the division results in a remainder of 0 instead, use '0' in that position. Stop when the division results in a value of 0. The resulting binary numbers are ordered from right to left.

For example, the decimal number **109** converts to binary as follows:

- 109 / 2 = 54 remainder
**1** - 54 / 2 = 27 remainder
**0** - 27 / 2 = 13 remainder
**1** - 13 / 2 = 6 remainder
**1** - 6 / 2 = 3 remainder
**0** - 3 / 2 = 1 remainder
**1** - 1 / 2 = 0 remainder
**1**

The decimal number 109 equals the binary number **1101101**.