|
|
Decimal Numbers Our normal number system uses place notation. The value of each digit is determined by two things: the digit itself, and where it is (its place) within the number. Because we use ten different digits (0 through 9), this system is called base-10, or decimal. Each place represents a different power of ten. Let’s use the number 8653 as an example.
From right to left,
Added all together, these give 8000 + 600 + 50 +3 = 8653. Why 10? Presumably because we have ten fingers, most human languages developed number systems based on the number ten. In fact, our word ‘digit’ comes from the Latin word digitus, meaning ‘finger’. But really, there’s nothing magical about the number ten, and any other number could serve as the basis of a place-value number system. The Mayans used a base-20 system, and the Babylonians had a base-60 system. |
Activities & Practice
1. What is the digit in the 104 place in the number 956,340? What is the digit in the 10² place? |
Analog and Digital In electronic computers, numbers need to be represented by voltages on wires. One way to do this is to have the number be proportional to the voltage. For example, for a scale of 1 Volt representing 1000, 2 Volts would represent 2000, and 8.653 Volts would represent the number 8653. Computers based on such systems are called analog computers, and there have been many analog computers built and used. There is an inherent flaw, though, with analog computers. Within any electronic circuit there is so-called noise, seemingly random voltage variations caused by the thermal motion of atoms in the wires and the voltages picked up by any wire from the electromagnetic fields radiated by other nearby wires (crosstalk). This noise is usually small --- a few tenths of a volt is typical, so it doesn’t make any difference in the power cord running a TV or blender, for instance. But in an analog computer, any noise would change the values of the numbers represented by those voltages --- bad news. Analog computers, therefore, have to be very carefully designed and built to minimize the effects of noise. A way to avoid the problems of analog computers is to have the voltages represent digits, rather than the numbers themselves. That's where the word ‘digital’ comes from. You could, for example, have the digit 0 represented by 0 Volts, 1 by 1 Volt, 2 by 2 Volts, and so forth, up to 9 Volts. The number 8653 then would be represented by four wires, carrying 8V, 6V, 5V, and 3V (this is called parallel) or perhaps instead by a single wire whose voltage changes from 8V to 6V to 5V then 3V (this is called serial). Any voltage near 5V would be interpreted as the digit ‘5’: 4.93V, 5.27V, 4.61V, 5.32V would all be ‘5’, eliminating the effects of noise, assuming the noise is less than 0.5V. Noise and crosstalk would have to get really bad before the data get corrupted. The fewer the digits, the less susceptible the system is to noise. This argues for having a system with only two digits, a binary system. Also, it is simpler to build circuits that respond to only two states, rather than ten. So, almost all digital computers use voltages to represent only two digits, 0 and 1.
|
|
Binary Numbers A number system using only two numerals, 0 and 1, is called binary, or base-2. Rather than calling the ones and zeros ‘digits’ (which, as mentioned above, comes from the Latin word for ‘finger’, sort of implying there are ten) the phrase ‘binary digit’ was often used, and then that got shortened to ‘bit’. In a binary number, each place is a different power of two. As an example,
let’s look at the binary number 1101.
Added all together, that gives us 8+4+0+1 or 13 (written in decimal). You can see that four bits (which is called a nibble, by the way) can represent, at most, the number 15. A byte is a group of 8 bits, which can represent any integer from 0 to 255. In general, a group of n bits can represent integers from 0 up to 2n-1. Let’s look at a longer example, a word (defined as 16 bits, or 2 bytes).
From right to left,
Adding all these up gives us 8192 + 256 + 128 + 64 + 8 + 4 + 1 = 8653 in decimal.
|
2. What is the decimal equivalent of the following binary numbers?
3. What is the bit in the 2² place in each of the above binary
numbers? 5. Write the decimal values of the powers of 2, from 20 up to and including 216. 6. Write the following decimal numbers in binary. 7. What is the decimal equivalent of each of these binary numbers?
|
Distinguishing Numbers Written In Different Bases When you see the number 1101, how do you know that is a binary number representing the decimal number thirteen, or the decimal number one thousand one hundred and one? Often it’s clear from the context of the discussion, but it’s handy to have a simple way to distinguish. From now on, if there's any possibility of confusion, we’ll end every binary number with a ‘b’, and every decimal number with a ‘d’.
|
|
Hexadecimal numbers As you saw from the example above, base-2 numbers require a lot of bits to represent any large quantity. For 8653d, we needed 14 bits --- we used a word (16 bits) but the first two leading bits were zeros. With so many 0’s and 1’s, it’s just confusing. It would be a lot easier to split the bits into groups of four (that is, into nibbles). Each nibble can represent a number from 0 to 15, and these can be represented by the digits 0 to 9, plus the letters A through F. In other words, we’re constructing a base-16, or hexadecimal, number system. We’ll use an ‘h’ at the end of a number to indicate that it is a hexadecimal number.
Let's look at our previous binary example:
Let's look at the place-values in hexadecimal.
adding these up gives us 8192 + 256 + 192 + 13 = 8653d |
8. Write these binary numbers in hexadecimal.
9. Write these hex numbers in binary.
10. Write these hex numbers in decimal.
11. Explain this amusing quote: "There are 10 kinds of people in the world - those who know binary and those who don't." |
|