Click here to purchase the entire book in PDF format.



next up previous contents index
Next: Hexadecimal (Base 16) Up: Binary, Decimal and Hexadecimal Previous: Decimal (Base 10)   Contents   Index


Binary (Base 2)

Imagine if we all had only two fingers instead of ten. We would probably have wound up with a different way of writing down numbers. We have ten digits (0 - 9) because we have ten fingers. If we only had two fingers, then it's reasonable to assume that we'd only have two digits - 0 and 1. This means that we have to re-think the way we construct the recycling of digits to make bigger numbers.

Let's count using this new two-digit system...

000 (zero)

001 (one)

Now what? Well, it's the same as in decimal, we increase our number to two digits and keep going.

010 (two)

011 (three)

100 (four)

This time, because we only have two digits, we multiply the digits in different locations by powers of two instead of powers of ten. So, for a big number like 10011, we can follow the same procedure as we did for base 10.


Table 1.3: A breakdown of an abritrary binary number 10011, converting it to a decimal number. Note that binary and decimal are used simultaneously in this table: to distinguish the two, all binary numbers are in italics.
1   0   0   1   1
Sixteen's   Eight's   Four's   Two's   One's
1 $* 2^{4}$ + 0 $ * 2^{3}$ + 0 $ * 2^{2}$ + 1 $ * 2^{1}$ + 1 $ * 2^{0}$
$1 * 16$ + $0 * 8$ + $0 * 4$ + $1 * 2$ + $1 * 1$
16 + 0 + 0 + 2 + 1
        = 19        


So, the binary number 10011 represents the same quantity as the decimal number 19. Remember, all we've done is to change the method by which we're writing down the same thing. ``19'' in base 10 and ``10011'' in base 2 both mean ``nineteen.''

This would be a good time to point out that if we add an extra digit to our binary number, we increase the number of quantities we can represent by a factor of two. For example: if we have a three-digit binary number, we can represent a total of eight different numbers (000 - 111 or zero to seven). If we add an extra digit and make it a four-digit number we can represent sixteen different quantities (0000 - 1111 or zero to fifteen).

There are a lot of reasons why this system is good. For example, let's say that you had to send a number to a friend using only a flashlight to communicate. One smart way to do this would be to flash the light on and off with a short ``on'' corresponding to a ``0'' and a long ``on'' corresponding to a ``1'' - so the number nineteen would be ``long - short - short - long - long.'' Some less-than-smart ways would be to bang your flashlight on a table nineteen times - or you could write the number ``19'' on the flashlight and throw it at your friend...

In the world of digital audio we typically use slightly different names for things in the binary world. For starters, we call the binary digits bits (get it? binary digits). Also, we don't call a binary number a ``number'' - we call it a binary word. Therefore ``1011010100101011'' is a sixteen-bit binary word.

Just like in the decimal system, there are a couple of quick math tasks that can be accomplished by shifting the bits (programmers call this bit shifting but be careful when you're saying this out loud to use it in context, thereby avoiding people getting confused and thinking that you're talking about dogs...)

If we take a binary word and bit shift it one place to the left (i.e. 111 becoming 1110) we are multiplying by two (in the previous example, 111 is seven, 1110 is fourteen).

Similarly, if we bit shift to the right, removing the right-most bit, we are dividing by two quickly, but frequently inaccurately. (i.e. 111 is seven, 11 is 3 - nearly half of seven) Note that, if it's an even number (therefore ending in a ``0'') a bit shift to the right will be a perfect division by zero (i.e. 1110 is fourteen, 111 is seven - half of fourteen). So if we bit shift for division, half of the time we'll get the correct answer and the other half of the time we'll wind up ignoring a remainder of a half.


next up previous contents index
Next: Hexadecimal (Base 16) Up: Binary, Decimal and Hexadecimal Previous: Decimal (Base 10)   Contents   Index
Geoff Martin 2006-10-15

Click here to purchase the entire book in PDF format.