Learn about the technologies behind the Internet with The TCP/IP Guide! NOTE: Using robot software to mass-download the site degrades the server and is prohibited. See here for more. Find The PC Guide helpful? Please consider a donation to The PC Guide Tip Jar. Visa/MC/Paypal accepted. View over 750 of my fine art photos any time for free at DesktopScenes.com!

The Mathematics of Computing

Humans represent numbers using decimal notation: that is, each digit can have one of ten values, zero through nine. This is also called base 10 mathematics and no doubt arose for biological reasons (we have ten fingers). Binary information uses only ones and zeros of course, which would be base 2 mathematics. Just as with regular numbers you start at 0, count to 9, and then reset the 9 to a 0 and add a 1 in the "tens" place, with binary information you start at 0, count to 1, then reset the 1 to a 0 and add a 1 in the "twos" place. So binary counting goes like this: 0, 1, 10, 11, 100, 101, 110, 111, 1000, etc. Each digit in a binary number is a bit, which is a contraction of "binary digit".

The number 111 is the binary equivalent of the decimal number 7. How? Just as 111 in decimal means 100 (10 to the second power) plus 10 (10 to the first power) plus 1, in binary 111 is 4 (2 to the second power) plus 2 (2 to the first power) plus 1, which is 7. As you can see, binary numbers can get pretty long. For example, the number 181 in decimal is 10110101 in binary. This can get quite cumbersome, and large numbers are often represented using 32, 64 or even more bits.

A shorthand for binary numbers is hexadecimal notation. These are numbers in base 16 mathematics. Each digit can take on any value from 0 to 15. Since 16 is 2 to the fourth power, four bits can take on a value from 0 to 15. This means 4 binary digits can be replaced by one equivalent hexadecimal digit. So 10110101 in binary can be broken into two 4-bit pairs, 1011 and 0101. These taken individually are 11 and 5, so 10110101 in binary is (11)5 in hexadecimal notation.

You can see the problem here of course: we only have 10 different symbols to represent numbers in our language, but hexadecimal requires 16! Having to use (11) in a single digit place is confusing. To get around this, hexadecimal numbers use the letters A through F to represent 10 through 15 (0 to 9 are of course represented by 0 to 9). So instead of saying (11)5, we say the decimal number 181 is "B5" in hexadecimal notation (or hex for short).

It can sometimes be hard to tell if a number is decimal or hexadecimal just by looking at it: if you just see "44", does that mean 44 ("44" in decimal) or 68 ("44" in hexadecimal)? To get around this problem, two common notations are used to indicate hexadecimal numbers. The first is the suffix of a lower-case "h". The second is the prefix of "0x". So "B5 in hexadecimal", "B5h" and "0xB5" all mean the same thing (as does the somewhat redundant "0xB5h"). A set of eight bits, or two hexadecimal digits, is called a byte. "B5h" is one byte of information. Bytes are commonly used when talking about how much information something can hold, because in most cases one byte is one character. Each character you read on this screen is represented by one byte (in most cases), as part of the ASCII character set.

Computer addresses are commonly expressed in hexadecimal notation. For example, the I/O port address commonly used by the computer to talk to your printer is address 378h. Note how the "h" helps you realize this is a hex number and not the decimal number "378".

Home  -  Search  -  Topics  -  Up

 The PC Guide (http://www.PCGuide.com) Site Version: 2.2.0 - Version Date: April 17, 2001© Copyright 1997-2004 Charles M. Kozierok. All Rights Reserved. Not responsible for any loss resulting from the use of this site. Please read the Site Guide before using this material.