Computer Basics Base Arithmetic
Computer Basics Base Arithmetic
number to count with. No doubt it has something to do with the number of counting tools available (fingers, that is!). There is nothing magic about ten, however, that makes it the best choice (except for those who count with those handy, dandy fingers). Some cultures have indeed used other numbers to count with. Babylon apparently used sixty, a sexagesimal numbering system, which has some calculating advantages since it divides evenly by two, three, four, five, six, ten, twelve, fifteen, twenty, and thirty. The simplest way of writing numbers is to make one mark for each thing counted. Note that our usual way of marking four vertical strokes and then a crossing stroke forms groups of five. Hmm. Five fingers on one hand. Any connection, do you think?? Once the number of cattle you own exceeds the number of fingers you have, it becomes clear that you need a short way of writing large numbers. Our modern system uses the position of a number symbol to indicate its real value. So our cattle ranchers don't have to scratch out several feet of little marks to write down the number of cows they have. Instead they write numbers like 4567. What that really means is 4 thousands plus 5 hundreds plus 6 tens plus 7 ones. So far so good. How does that relate to using other bases? Look at how this works. Base 10 a thousand 10 x 10 x 10= = a hundred = ten = 10 x 10= 10= 103 102 101
one =
1=
100
This way of writing 10 x 10 x 10 as 103 names 3 as the power of 10. So we could write our number as powers of 10 this way: (4 x 103)+ (5 x 102)+ (6 x 101)+ (7 x 100 ) Each digit is multiplied by a power of 10 to get the complete number. We can use this same kind of notation with any base. We just need to know what the base is and what the symbols are for the numbers smaller than the base.
Computers don't have ten fingers to count with. All they have is on and off.
Everything inside a computer must be represented with some combination of on and off. We humans use the digits 1 for on and 0 for off. We call this base 2 since there are only 2 symbols used. A sequence of on off off on off on on off on is written for the benefit of humans as 100101101. This is only a little bit better but it takes less energy to write down. Suchbase 2 numbers are called binary numbers. Now the number 100101101 in base 2 uses the same symbols as 100,101,101 in base ten. But the base 10 number is equal to one hundred million one hundred and one thousand one hundred and one. This is a much larger number than the base 2 number. The 1s and 0s must be multiplied by powers of 2 to see how many cows this number represents. 100101101 in base 2 1 x 28 = 0 x 27 = 0x 0x 26 24 = = 1 x 25 = 1 x 256 0 x 128 0 x 64 1 x 32 0 x 16 = in base 10 256 0 0 32 0
1 x 23 = 1 x 22 = 0 x 21 = 1 x 20 = Total =
8 4 0 1 301 in base 10
For example, adding the two numbers below: (don't forget to carry a one over if the column is 1 + 1 = 10) 10101101 + 1011110 100001011
Because people have a really hard time keeping straight numbers like those
above, computer numbers are often written in yet another base - base 16. Such numbers are called hexadecimal. Hexadecimal numbers look really odd because they have more symbols than we are used to. Letters are used for the numbers from ten through fifteen: A = 10; B = 11; C = 12; D = 13; E = 14; F = 15. They can be either upper case or lower case. The numbers we added above if written as base 16 numbers look like: 3F2 + B37 F29 To interpret such numbers as base 10 numbers, ( for those of us who just can't quit counting on our fingers!) you need to know the powers of 16. 163 = 4096
162 = 256 161 = 16 160 = 1 So the number F29 in base 16 is equal to: (F x 162)+ (2 x 161)+ (9 x 160 ) = 15 x 256 = 3840 2 x 16 = 32 9 x 1 = 9 3881 in base 10 This is certainly not all that easy to do. Few people can multiply 15 by powers of 16 easily. But the really advantage for base 16 is in how easy it is to change from base 2 to base 16 and back. Every hexadecimal digit is broken down into a 4 digit binary number. These digits are just written down in the same order as the hexadecimal number and you've got the equivalent binary (base 2) number. For our number F29 : F is equal to 15 which is 8 + 4 + 2 + 1. (These are the powers of 2). That means that F = (1 x 23) + (1 x 22) + (1 x 21) + (1 x 20).
(We'll use little numbers at the bottom, called subscripts, to show what base the number is using)
So F16 = 11112 Since 216 is (1 x 21), then 216 = 00102 Since 916 is (1 x 23 ) + (1 x 20), then 916 = 10012 Putting this together makes F2916 = 1111001010012. Once you learned how to write the numbers 0 to 15 in base 2, you could whip back and forth between base 2 and base 16 rapidly. Some folks who work with computers have to do just that.
Thank goodness most of us don't have to do this all the time! One number
system is enough to deal with!! But now you know a little about the numbers computers think with and how people write them down.
vWhy
Binary numbers seen as strings of 0's and 1's are often associated with computers. But why is this? Why can't computers just use base 10 instead of converting to and from binary? Isn't it more efficient to use a higher base, since binary (base 2) representation uses up more "spaces"? I was recently asked this question by someone who knows a good deal about computers. But this question is also often asked by people who aren't so tech-savvy. Either way, the answer is quite simple.
What is "digital"?
A modern-day "digital" computer, as opposed to an older "analog" computer, operates on the principle of two possible states of something "on" and "off". This directly corresponds to there either being an electrical current present, or said electrical current being absent. The "on" state is assigned the value "1", while the "off" state is assigned the value "0". The term "binary" implies "two". Thus, the binary number system is a system of numbers based on two possible digits 0 and 1. This is where the strings of binary digits come in. Each binary digit, or "bit", is a single 0 or 1, which directly corresponds to a single "switch" in a circuit. Add enough of these "switches" together, and you can represent more numbers. So instead of 1 digit, you end up with 8 to make a byte. (A byte, the basic unit of storage, is simply defined as 8 bits; the well-known kilobytes, megabytes, and gigabytes are derived from the byte, and each is 1,024 times as big as the other. There is a 1024-fold difference as opposed to a 1000-fold difference because 1024 is a power of 2 but 1000 is not.)
Non-binary computers
Imagine a computer based on base-10 numbers. Then, each "switch" would have 10 possible states. These can be represented by the digits (known as "bans" or "dits", meaning "decimal digits") 0 through 9. In this system, numbers would be represented in base 10. This is not possible with regular electronic components of today, but it is theoretically possible on a quantum level. Is this system more efficient? Assuming the "switches" of a standard binary computer take up the same amount of physical space (nanometers) as these base-10 switches, the base-10 computer would be able to fit considerably more processing power into the same physical space. So although the question of binary being "inefficient" does have some validity in theory, but not in practical use today.
This page will explain the significance of different-base number systems, and how important they are to the field of computing.
Introduction
The base number system we are all familiar with is 10 [Decimal]. With it we use ten unique integers: 0123456789 After the number nine comes 10. Notice that 10 is not a unique number; it is a combination of two unique numbers. The numbers 10-19 are the second iteration of the base 10 system, 20-29 are the third iteration, and so forth.
The base 8 system (Octal) uses only the integers 0-7, so counting with it would look like this: 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 ... After 7 comes 10, which starts the second iteration in the octal system. 10 in octal is not the same as 5+5; you can see it is the equivalent of 8 in decimal. Likewise, 20 octal is 16 in decimal, 100 octal is 64 decimal.
Now we take a look at the base 2 number system [binary]. The only unique integers in this system are 0 and 1. Counting with it looks like this: 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 ... The number 10000 binary is the equivalent of 16 in decimal and 20 in octal.
We have looked at the decimal, octal and binary number systems. When a base-number system is greater than 10, additional integers besides 0-9 must be used. The base 16, or hexadecimal system, is a good example. Because we don't have 16 unique integers in our numbering, we use letters to fill integers after 9. So hexadecimal counting looks like this: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A ... E4 E5 ... F9 FA ...
A look at different base systems:
When expressing large numbers, the binary system is very inefficient, as is any low base system. Higher base systems can express numbers using fewer characters. To illustrate this, we will look at a table showing numbers as they would look in different base systems. The columns are different systems: Base 2, 3, 4, 8, 9, 10, 16, and 18. The rows are different numbers as they look in each system.
*2*
10 1,000 11,011
*3*
2 22 1,000
*4*
2 20 123
*8*
2 10 33
*9*
2 8 30
*10*
2 8 27
*16* *18*
2 8 1B 2 8 19