Egyptian Numerals
Total Page:16
File Type:pdf, Size:1020Kb
• 30000BC Palaeolithic peoples in central Europe and France record numbers on bones. • 5000BC A decimal number system is in use in Egypt. • 4000BC Babylonian and Egyptian calendars in use. • 3400BC The first symbols for numbers, simple straight lines, are used in Egypt. • 3000BC The abacus is developed in the Middle East and in areas around the Mediterranean. A somewhat different type of abacus is used in China. • 3000BC Hieroglyphic numerals in use in Egypt. • 3000BC Babylonians begin to use a sexagesimal number system for recording financial transactions. It is a place-value system without a zero place value. • 2000BC Harappans adopt a uniform decimal system of weights and measures. • 1950BC Babylonians solve quadratic equations . • 1900BC The Moscow papyrus is written. It gives details of Egyptian geometry. • 1850BC Babylonians know Pythagoras 's Theorem. • 1800BC Babylonians use multiplication tables. • 1750BC The Babylonians solve linear and quadratic algebraic equations, compile tables of square and cube roots. They use Pythagoras 's theorem and use mathematics to extend knowledge of astronomy. • 1700BC The Rhind papyrus (sometimes called the Ahmes papyrus) is written. It shows that Egyptian mathematics has developed many techniques to solve problems. Multiplication is based on repeated doubling, and division uses successive halving. • 1360BC A decimal number system with no zero starts to be used in China. • 1000BC Chinese use counting boards for calculation. • 540BC Counting rods used in China. • 500BC The Babylonian sexagesimal number system is used to record and predict the positions of the Sun, Moon and planets. Egyptian Numerals Egyptian number system is additive. Mesopotamia Civilization Above: Babylonian sexagesimal (base 60) number. It is the first positional number system. Left: Oldest cuneiform writing by Sumerian. Babylonian numerals Chinese numerals 4359 Indian numerals Greek number systems Roman Numerals I 1 VI 6 L 50 II 2 VII 7 C 100 III 3 VIII 8 D 500 IV 4 IX 9 M 1000 V 5 X 10 MMMDCCCLXXVIII 3878 Mayan mathematics 250 AD to 900 AD, this period was built on top of a civilization which had lived in the region from about 2000 BC. [8;14;3;1;12] represents 12 + 1 x 20 + 3 x 18 x 20 + 14 x 18 x 20 2 + 8 x 18 x 20 3 = 1253912. The numerals from al-Sizji's treatise of 969 Abaci Chinese Abacus Boethius (Hindu-Arabic) vs Pythagoras (counting board) Logarithm and Slide Rule John Napier of Scotland developed the concept of logarithm around AD 1600. Slide rule based on the property of logarithm was invented in the late 1700s. y If a =x, then y = log ax log ( u v) = log ( u) + log( v) Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3) + (2x10 2) + (7x10 1) + (1x10 0) Numbers: positional notation • Number Base B ⇒ B symbols per digit: – Base 10 (Decimal): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 2 (Binary): 0, 1 • Number representation: – d31 d30 ... d 1d0 is a 32 digit number × 31 × 30 × 1 × 0 – value = d31 ×× B + d30 ×× B + ... + d1 ×× B + d0 ×× B • Binary: 0,1 (In binary digits called “bits”) – 0b11010 = 1×××24 + 1×××23 + 0×××22 + 1×××21 + 0×××20 = 16 + 8 + 2 = 26 – Here 5 digit binary # turns into a 2 digit decimal # – Can we find a base that converts to binary easily? #s often written 0b… Hexadecimal Numbers: Base 16 • Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F – Normal digits + 6 more from the alphabet – In C, written as 0x … (e.g., 0xFAB5) • Conversion: Binary ⇔Hex – 1 hex digit represents 16 decimal values – 4 binary digits represent 16 decimal values ⇒1 hex digit replaces 4 binary digits • One hex digit is a “ nibble ”. Two is a “ byte ” • Example: – 1010 1100 0011 (binary) = 0x_____ ? Decimal vs. Hexadecimal vs. Binary Examples: 00 0 0000 01 1 0001 1010 1100 0011 (binary) 02 2 0010 = 0xAC3 03 3 0011 04 4 0100 10111 (binary) 05 5 0101 = 0001 0111 (binary) 06 6 0110 = 0x17 07 7 0111 08 8 1000 0x3F9 09 9 1001 = 11 1111 1001 (binary) 10 A 1010 How do we convert between hex and 11 B 1011 Decimal? 12 C 1100 13 D 1101 14 E 1110 15 F 1111 What to do with representations of numbers? • Just what we do with numbers! – Add them – Subtract them – Multiply them 1 1 – Divide them 1 0 1 0 – Compare them • Example: 10 + 7 = 17 + 0 1 1 1 – …so simple to add in binary that we can build circuits to do it! – subtraction just as you would in decimal ------------------------- – Comparison: How do you tell if X > Y ? 1 0 0 0 1 Which base do we use? • Decimal: great for humans, especially when doing arithmetic • Hex: if human looking at long strings of binary numbers, its much easier to convert to hex and look 4 bits/symbol – Terrible for arithmetic on paper • Binary: what computers use; you will learn how computers do +, -, *, / – To a computer, numbers always binary – Regardless of how number is written: 32 ten == 32 10 == 0x20 == 100000 2 == 0b100000 – Use subscripts “ten”, “hex”, “two” in book, slides when might be confusing BIG IDEA: Bits can represent anything!! • Characters? – 26 letters ⇒ 5 bits (2 5 = 32) – upper/lower case + punctuation ⇒ 7 bits (in 8) (“ASCII”) – standard code to cover all the world’s languages ⇒ 8,16,32 bits (“Unicode”) www.unicode.com • Logical values? – 0 ⇒ False, 1 ⇒ True • colors ? Ex: • locations / addresses? commands? • MEMORIZE: N bits ⇔ at most 2 N things Red (00) Green (01) Blue (11) How to Represent Negative Numbers? • So far, un signed numbers • Obvious solution: define leftmost bit to be sign! – 0 ⇒ +, 1 ⇒ - – Rest of bits can be numerical value of number • Representation called sign and magnitude • MIPS uses 32-bit integers. +1 ten would be: 0000 0000 0000 0000 0000 0000 0000 0001 • And –1ten in sign and magnitude would be: 1000 0000 0000 0000 0000 0000 0000 0001 Shortcomings of sign and magnitude? • Arithmetic circuit complicated – Special steps depending whether signs are the same or not • Also, two zeros – 0x00000000 = +0 ten – 0x80000000 = -0ten – What would two 0s mean for programming? • Therefore sign and magnitude abandoned Another try: complement the bits • Example: 710 = 00111 2 -710 = 11000 2 • Called One’s Complement • Note: positive numbers have leading 0s, negative numbers have leadings 1s. 00000 00001... 01111 10000 ... 11110 11111 • What is -00000 ? Answer: 11111 • How many positive numbers in N bits? • How many negative ones? Shortcomings of One’s complement? • Arithmetic still a somewhat complicated. • Still two zeros – 0x00000000 = +0 ten – 0xFFFFFFFF = -0ten • Although used for awhile on some computer products, one’s complement was eventually abandoned because another solution was better. Standard Negative Number Representation • What is result for unsigned numbers if tried to subtract large number from a small one? – Would try to borrow from string of leading 0s, so result would have a string of leading 1s » 3 - 4 ⇒ 00…0011 - 00…0100 = 11…1111 – With no obvious better alternative, pick representation that made the hardware simple – As with sign and magnitude, leading 0s ⇒ positive, leading 1s ⇒ negative » 000000...xxx is ≥ 0, 111111...xxx is < 0 » except 1…1111 is -1, not -0 (as in sign & mag.) • This representation is Two’s Complement Sign and Magnitude -7 +0 -6 1111 0000 +1 Example: N = 4 1110 0001 -5 +2 + 1101 0010 -4 1100 0011 +3 0 100 = + 4 -3 1011 0100 +4 1 100 = - 4 1010 0101 -2 +5 - 1001 0110 -1 1000 0111 +6 -0 +7 High order bit is sign: 0 = positive (or zero), 1 = negative Remaining low order bits is the magnitude: 0 (000) thru 7 (111) Number range for n bits = +/- 2n-1 - 1 Representations for 0? Operations: =, <, >, +, - ??? Ones Complement (algebraically) N is positive number, then N is its negative 1's complement 4 N = (2 n - 1) - N 2 = 10000 -1 = 00001 Example: 1's complement of 7 1111 -7 = 0111 1000 -7 in 1's comp . Bit manipulation: simply complement each of the bits 0111 -> 1000 Ones Complement on the number wheel -0 +0 -1 1111 0000 +1 1110 0001 -2 +2 + 1101 0010 -3 1100 0011 +3 0 100 = + 4 -4 1011 0100 +4 1 011 = - 4 1010 0101 -5 +5 - 1001 0110 -6 1000 0111 +6 -7 +7 Subtraction implemented by addition & 1's complement Sign is easy to determine Closure under negation. If A can be represented, so can -A Still two representations of 0! If A = B then is A – B == 0 ? Addition is almost clockwise advance, like unsigned Twos Complement number wheel -1 +0 -2 1111 0000 +1 1110 0001 -3 +2 + like 1's comp 1101 0010 except shifted -4 1100 0011 +3 0 100 = + 4 one position clockwise -5 1011 0100 +4 1 100 = - 4 1010 0101 -6 +5 - 1001 0110 -7 1000 0111 +6 -8 +7 Easy to determine sign (0?) Only one representation for 0 Addition and subtraction just as in unsigned case Simple comparison: A < B iff A – B < 0 One more negative number than positive number - one number has no additive inverse Twos Complement (algebraically) N* = 2 n -N 4 2 = 10000 Example: Twos complement of 7 sub 7 = 0111 1001 = repr. of -7 4 Example: Twos complement of -7 2 = 10000 sub -7 = 1001 0111 = repr. of 7 Bit manipulation: Twos complement: take bitwise complement and add one 0111 -> 1000 + 1 -> 1001 (representation of -7) 1001 -> 0110 + 1 -> 0111 (representation of 7) How is addition performed in each number system? • Operands may be positive or negative Sign Magnitude Addition Operand have same sign: unsigned addition of magnitudes 4 0100 -4 1100 result sign bit is the same as the operands' + 3 0011 + (-3) 1011 sign 7 0111 -7 1111 Operands have different signs: subtract smaller from larger and keep sign of the larger 4 0100 -4 1100 - 3 1011 + 3 0011 1 0001 -1 1001 Ones complement addition Perform unsigned addition, then add in the end-around carry