# How to Understand Binary (And Octal and Hexadecimal) Numbers

When you get into computing you may come across binary numbers (which are used internally by the computer) as well as hexadecimal or octal numbers. Here's an explanation of how they work:

Base 10

In the familiar (base 10) system, each column of a number represents a number times a power of ten (units, tens, hundreds, thousands, etc.).

You should also notice that only the digits less than 10, that is to say from 0 to 9, are used in the base 10 system.

For example:

1234 = ( 1 * ( 10 ^ 3 ) ) + ( 2 * ( 10 ^ 2 ) ) + ( 3 * ( 10 ^ 1 ) ) + 4

1234 = ( 1 * 1000 ) + ( 2 * 100 ) + ( 3 * 10 ) + 4

Binary (Base 2)

In the binary numbering sytem (base 2) each column of numbers represents a number times a power of two (units, twos, fours, eights, etc.).

You should also note that only the digits less than 2, that is to say 0 and 1, are used in the binary system. Additionally, it is worth knowing that many binary numbers are written with preceding zeroes.

For example:

00001011 (binary) = ( 1 * ( 2 ^ 3 ) ) + ( 0 * ( 2 ^ 2 ) ) + ( 1 * ( 2 ^ 1 ) + 1

00001011 (binary) = ( 1 * 8 ) + ( 0 * 4 ) + ( 1 * 2 ) + 1

00001011 (binary) = 8 + 0 + 2 + 1

00001011 (binary) = 11 (decimal)

Octal (Base 8)

The octal numbering system (base 8) works on the same principle, except instead of powers of ten (or two), powers of eight are used (units, 8s, 64s, etc.). Only the digits less than 8, namely 0 to 7, are used in the octal numbering system.

The hexadecimal numbering system (base 16) also works on the same principles, except powers of sixteen are used (units, 16s, 256s, etc.). Digits are used in the range 0 to 15 (i.e. less than 16). Since we need a single character representation (a digit) for the numbers 10 to 15, letters are used as digits for values of 10 to 15 (10 is A, 11 is B, 12 is C, 13 is D, 14 is E, 15 is F).

Quick Conversion Table

You can use this table to translate between bases:

0 (base 10) = 0000 (binary) = 0 (octal) = 0 (hexadecimal)

1 (base 10) = 0001 (binary) = 1 (octal) = 1 (hexadecimal)

2 (base 10) = 0010 (binary) = 2 (octal) = 2 (hexadecimal)

3 (base 10) = 0011 (binary) = 3 (octal) = 3 (hexadecimal)

4 (base 10) = 0100 (binary) = 4 (octal) = 4 (hexadecimal)

5 (base 10) = 0101 (binary) = 5 (octal) = 5 (hexadecimal)

6 (base 10) = 0110 (binary) = 6 (octal) = 6 (hexadecimal)

7 (base 10) = 0111 (binary) = 7 (octal) = 7 (hexadecimal)

8 (base 10) = 1000 (binary) = 10 (octal) = 8 (hexadecimal)

9 (base 10) = 1001 (binary) = 11 (octal) = 9 (hexadecimal)

10 (base 10) = 1010 (binary) = 12 (octal) = A (hexadecimal)

11 (base 10) = 1011 (binary) = 13 (octal) = B (hexadecimal)

12 (base 10) = 1100 (binary) = 14 (octal) = C (hexadecimal)

13 (base 10) = 1101 (binary) = 15 (octal) = D (hexadecimal)

14 (base 10) = 1110 (binary) = 16 (octal) = E (hexadecimal)

15 (base 10) = 1111 (binary) = 17 (octal) = F (hexadecimal)

Computer programmers often use octal and hexadecimal as a short hand for binary because each digit in hexadecimal corresponds to 4 binary digits, and each digit in octal corresponds to 3 binary digits.

For example:

0101 1111 (binary) = 5F (hexadecimal) = ( 5 * 16 ) + 15 = 95 (base 10)

or

0101 1111 (binary) = 01 011 111 (binary) = 137 (octal) = ( 1 * 64 ) + ( 3 * 8 ) + 7 = 95 (base 10)

By S. Tanna for Answers 2000, first published at http://www.wildcomputer.com/art_genbin.php

For more computer tips, plus software & hardware shopping visit http://www.wildcomputer.com/

Source: www.a1articles.com

# #