# Binary Numbers

Choose Subtopic

Converting back and forth between decimal and binary is easy. First, if you're a Windows user, pop up the Accessories Calculator. Set View to Scientific. Type in a decimal number, click "Bin" in the upper left, just below the data entry box, and there's the binary equivalent. Similarly, type in a string of 0's and 1's, click "Dec," and there's the decimal value. How does that work? Let's do one conversion each way.

84 (base 10) is between 26 = 64 and 27 = 128. That says we'll need 7 bits to express 84 in binary, and the most significant position will be a 1 in the 6th place. That 1 will represent 64 out of 84 counts, leaving 20 (84-64) to be encoded. So at this point, we have 1xxxxxx. The next position, 25, has a decimal value of 32. But 32 is bigger than 20, so this position gets a 0, and we have 10xxxxx. The next position is 24 = 16, which is less than 20. So that gets set to 1, and we have 101xxxx with a remainder to be encoded of 20 - 16 = 4. We recognize that 22=4, so the 4's place will have 1 and all the other places will have 0's, so the encoding is 1010100. Here's a shortcut: ALL odd numbers will have a 1 in the 1's place.

What if we're going in the other direction -- converting base 2 to base 10? Just add up the place values (from the table you filled in) anywhere you see a 1, and ignore the places where there's a 0. 1001001 = 1×26+1×23+1×20 = 64+8+1 = 73.

Incidentally, characters such as those you're reading right now are also encoded in binary. For simple alphabetic characters, the ASCII encoding is common. To enable use of all the character sets of all the languages of the world, Unicode is employed.