 Number Systems

A number system is quite simply a way of representing numbers. The one you know best is the decimal number system which consists of 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 and is the most commonly used number system. We say the "base" of the decimal system is 10 because there are 10 digits represented in it: 0 thru 9. We use the combination of these 10 digits to form all other numbers. The value of a digit in a number depends upon its position in the number. Take for example the decimal number 2448:

 Power of 10: 103 102 101 100 Placevalue: 1000 100 10 1 Digits: 2 4 4 8 Decimals: 2000 400 40 8
Each place in a decimal number
is a power of 10. So, our number, 2448, is:
2000 +
400 +
40 +
8
=  2448

Some say we came up with the decimal number system because we have 10 fingers! Could be!

But the decimal system isn't the only number system. Especially since computers came around, other number systems have come into widespread usage. Since a computer finds it easy to have an electronic circuit be either "on" or "off" (like a light switch), computers like a number system that has only 2 numbers: 0 (off) and 1 (on). So, each binary digit ("bit") in a computer is like a digit in the decimal system. Where the decimal system has the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, the binary system has only 0 and 1. Just as the decimal system has place representations for powers of 10 (1,10, 100, . . .) and for numbers less than 1 (1/10, 1/100, 1/1000 . . .) , the binary system has place representations for each power of 2: (1, 2, 4, 8, 16, . . .) and for numbers less than 1: (1/2, 1/4, 1/8, 1/16 . . .)

A number in the binary system is rather boring. They look like this: "0 0 1 0 0 1 1". Each "bit", starting at the right, is a power of 2. For our 7-bit example, the powers of 2 are:

 Power of 2: 26 25 24 23 22 21 20 Place value: 64 32 16 8 4 2 1 Bits: 0 0 1 0 0 1 1 Decimals: 0 0 16 0 0 2 1
This binary number, 0010011, in decimal, is 16 + 2 + 1 = 19.

Each 1 or 0 tells you whether that power of 2 is in the number. In our above example, the number is 7 'bits' long and tells you which of the powers of 2 up to 26 are in the number. In our example, we have a 1 in the one's place, a 1 in the 21 place and a 1 in the 24 place. Since 24 is 2x2x2x2 = 16, our number 0010011 is the decimal number 16 + 2 + 1 =19. Get it?

Another number system you see sometimes, also associated with computers, is the hexadecimal number system, a system based on the number 16. "Hexa" meaning 6 and "decimal" meaning 10 gives you 6 + 10 = 16. Hexadecimal has digits that go all the way up to 15. For this they had to "invent" digits above 9, so they just started with the alphabet:
digit:    0   1  2  3  4  5  6  7  8  9   A   B   C    D     E   F
value:     0   1  2  3  4  5  6  7  8  9  10  11  12   13   14  15
The main reason for hexadecimal was just to make the input and output of the computer easier and more readable. Here is our table for the hexadecimal number 2FE:

 Power of 16: 163 162 161 160 Place value: 4096 256 16 1 Digits: 0 2 F E Decimals: 0x4096 = 0 2x256 = 512 15x16 = 240 14x1 = 14

So, our hexadecimal number, 2FE, is, in decimals,    512 + 240 + 14 = 766.
Think about it. Our 3-digit hexadecimal number, 2FE is, in binary, 1011111110. 2FE is a lot easier to read and to input. If you were inputting numbers like 1011111110 into the computer it would be easy to miss a 1 and mess that up! A computer doesn't actually do arithmetic in hexadecimal. It just uses it to communicate with the outside world!

When you're dealing with more than one number system, you indicate the base of your number with a little subscript. Our example would become:
2FE16 = 10111111102 = 76610
You can see that without that little subscript, a number like 286 would be confusing. It is quite different in decimal or hexadecimal. 286 is a valid number in both systems!
It isn't valid in binary because it contains digits other than 0 or 1.
28610 is just 286, where 28616 is 64610 or, if you're interested, 10100001102

There are other number systems out there. Octal, based on the number 8, was used early in the computer world but is no longer used. You could even make up a system based on the number 7 where the number 1667 would be
1 x72 + 6 x71 + 6 x70
=  49    + 42     + 6       = 9710, but it wouldn't be very useful!

By the way, if you want to be cool, you call hexadecimal numbers "hex"!