Number Systems © Noel Murphy, DCU, 2000
Total Page:16
File Type:pdf, Size:1020Kb
Number Systems © Noel Murphy, DCU, 2000 A number system is just a way of writing numbers. We use a positional number system with ten symbols, 0 - 9, where the position of a symbol indicates its value. So for example, the 9 in 911 represents nine hundred things, while the 9 in 119 only represents nine things. It was not always like this. Egyptian Numbers Around 5000 BC (2000 years before Newgrange was built and 3000 years before the pyramids were built) the Egyptians had a number system based on powers of ten, but with different symbols for ten, one hundred, one thousand, etc. Instead of a symbol to represent the number three, they would write the appropriate symbol three times. Modern: 1 10 100 1000 10,000 100,000 1000,000 Egyptian: Thus the number 234 (for us) would be written by an ancient Egyptian as two snares, three heel bones and four vertical strokes: Roman Numerals The Romans used a number system based on the value five, represented by the letter V (which probably represented a hand with the fingers together and the thumb at an angle to them). This is called a quintal system from the Latin quintus meaning a fifth. Again there are special symbols for the bigger numbers, like X for ten, L for fifty, C for one hundred, D for five hundred and M for one thousand. It was also positional, but not in the modern sense. The symbols to the left of a larger symbol were to be subtracted to find the value represented, while ones appearing on the right were to be added. Thus IV represents five minus one, or four, while VI represents five plus one, or six. Babylonian Number Systems Around 3000BC, the Babylonians in Mesopotamia (modern Iraq) used a number system based on the value sixty. They used two wedge-shaped (cuneiform) marks, for one and for ten, where the position of the symbol indicated its value. Thus represented two sixties plus ten plus one (131 in our system). The Babylonian use of sixty as their base number is the origin of our use of 60 seconds in a minute, and 60 minutes in an hour. It is also the origin of our convention of 360 degrees in a complete circle and use of “minutes of arc” and “seconds of arc” for fractions of a degree. The Babylonians were very interested in astronomy and the two things you need to study astronomy are measures of time and angles. It was 300BC before the Babylonians started to use a special symbol to denote an empty space between other positional symbols (i.e., to indicate a zero, as in 105, meaning one hundred, no tens and five units in our system). However, they still did use not zeros on the right hand side of a number to give the scale of a number. Instead they used a sophisticated system that we now call floating point where the scale of a number is known or given separately. Thus they would write the numbers 1 30 , 2, 120 and 7200 in exactly the same way, with the scale being inferred from the context. This system allowed then to carry out multiplication very easily, whereas the later Roman numeral system made multiplication almost impossible. Actually the Babylonians also used numbers written in groupings based on tens and hundreds for normal business transactions and used the base sixty numbers just for the more difficult problems. The History Of Our Number System Our number system with its positional notation and base (or radix) ten, was first used in India in AD 595, though the earliest use of this system with a zero is from AD 876. Again, the main motivation for the use of a proper number system was astronomy. The system was adopted by the Moors, and later was introduced to Europe, principally through translations of a book called Algebra by an Arab mathematician called al-Khwarizmi. His name has given us the word “algorithm” meaning a procedure, particularly in the context of computer programs. (The word “algebra” is from the Arabic “al-jabr w’al-muqabala” meaning “restoration and reduction”). The use of positional notation for fractions was introduced around 1579 by Francois Viete. Before this, fractions were usually represented in the “degrees, minutes, seconds” notation that we still use for fractions of an angle. The dot for a decimal point was popularised in the English-speaking world by the Scottish mathematician John Napier, who invented logarithms. (In continental Europe, a comma is usually used instead of a dot for the decimal “point”). The development of decimal fractions during the Middle Ages was often motivated by attempts to find accurate representations of the value of p. A Persian mathematician who died c.1436 calculated the value of 2p correct to 16 decimal places. The Denary System In our system, a denary system, the position of a symbol to the left of the decimal point represents numbers of increasing powers of ten, while digits to the right of the decimal point represent decreasing fractions of ten. So 735.24 = 7 ´102 + 3´101 + 5´ 100 + 2 ´ 10-1 + 4 ´ 10-2 The Binary System In this century, the inventors of the computer, such as the Hungarian mathematician John Von Neumann, decided that as the simplest electronic circuit could be in just two states: ON or OFF, it would be useful to represent numbers in a binary system with two symbols or digits, “1” and “0”. The binary system used is exactly the same as the denary system except that powers of two are used instead of powers of ten. So 1101.11 1 23 1 22 0 21 1 20 1 2-1 1 2-2 2 = ´ + ´ + ´ + ´ + ´ + ´ 1 1 = 1´ 8 + 1´ 4 + 0´ 2 + 1´1 + 1´ 2 + 1´ 4 13.75 = 10 To convert from base ten to base two, we have to deal with the two sides of the binary point separately (its not a decimal point any more).1 For the number to the left of the binary point we repeatedly divide by 2 until there is nothing left. The binary whole number is then the remainders read from the bottom up. 13 2 6 remainder 1 10 ¸ = 610 ¸ 2 = 3 remainder 0 310 ¸ 2 = 1 remainder 1 110 ¸ 2 = 0 remainder 1 13 1101 That is 10 = 2 . 1 The general term for the dot used to separate the fractional part of a number from the integer part applicable to all number bases is the radix point. “Radix” is another word for the base to which a positional number system is defined. For the binary digits to the right of the decimal point we repeatedly multiply by 2, and take the fractional part for the next step, until there is nothing left. The binary fractional number is then the set of whole ones and zeros we got in the multiplication process, reading from the top. 0.6875 2 1.375 1 0.375 10 ´ = = + 0.37510 ´ 2 = 0.75 = 0 + 0.75 0.7510 ´ 2 = 1.5 = 1+ 0.5 0.510 ´ 2 = 1 = 1+ 0.0 0.6875 0.1011 That is, 10 = 2 . In principle we can carry out this process to convert to and from base ten or denary numbers and any other base, but in principle only a few others have had any widespread usage. The most popular ones in computer engineering are base eight (or octal) and base sixteen (or hexadecimal). Binary number systems are actually much older than our “computer age”. The medieval English units for the measure of quantities of liquid went as follows: 2 gills = 1 chopin 2 chopins = 1 pint 2 pints = 1 quart 2 quarts = 1 pottle 2 pottles = 1 gallon 2 gallons = 1 peck 2 pecks = 1 demibushel 2 demibushels = 1 bushel or firkin 2 firkins = 1 kilderkin 2 kilderkins = 1 barrel 2 barrels = 1 hogshead 2 hogsheads = 1 pipe 2 pipes = 1 tun How many do you recognise? The first published work on the binary number system as such, was by a Spanish bishop, Juan Caramuel in 1670. Charles XII of Sweden began to promote, in 1717, the use of base 8 or base 64 for calculation, but died in battle before he could make a decree to this effect. Hexadecimal Engineers usually use the word “bit” as a contraction for the term “binary digit”. Over the last twenty years, engineers and computer scientists have designed and built computers with things internally grouped in multiples of eight bits, sixteen bits, thirty-two bits, and more recently sixty-four bits. These are all multiples of four bits and it is always possible to represent four bits with one hexadecimal digit, so for convenience, engineers and computer scientists usually use hexadecimal, or base sixteen numbers, at least at the level of the “nuts and bolts” of the computer. The problem with base sixteen is that we need sixteen different symbols or digits. (In base ten these are 0-9 and in base two they are 0 and 1). Usually we use the letters A to F to represent the numbers ten to fifteen, so the digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. So 3 2 1 0 A1CF16 = 10´16 + 1´16 + 12 ´16 + 15´16 = 10´ 4096 + 1´ 256 + 12 ´16 + 15´1 = 40960 + 256 + 192 + 15 41423 = 10 The biggest number we can write with four hexadecimal digits (or thirty-two bits) is FFFF 65535 32767 16 = 10 .