What is a number?
Numbers and their Representations
Tally Mark Arithmetic One measure of a number system's usefulness is the ease of arithmetic. This is a system for representing positive integers. How do you do the four basic operations?
- + concatenate
- - for each mark in the smaller number, erase one in the larger. What's left is the difference.
- * for each tally mark in one number, make a copy of the other. Glue 'em together.
- // (integer division) keep choping copies of the divisor out of the dividend. The number of chops is the integer quotient. The number left stranded is mod.
- % (mod)
What's the big shortcoming of this system?
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
This is unwieldy and uncompact!
Denominational Numbering Systems Roman numerals and US currency are examples of this.
What are the advantages of Roman numerals over tally marks? What are the disadvantages?
1 I 2 II 5 V 10 X 20 XX 50 L 100 C 500 D 1000 M MCMLVII DCLXXX What sucks? Arithmetic is PITA.
It is interesting to note that the Mayan Numbering System is far superior to Roman numerals when it comes to arithmetic. It is based on 5 and 20.
Discussion Do you think there is a tie between number systems and human progress?
Exercise Given that US currency is issued in denominations of $1, $2, $5, $10, $20, $50, $100, write a procedure to count out an integer number of dollars using as few bills as possible
How succinctly can you write this procedure? Do you need to use any symbols at all?
From Leo Atalla to Everyone: (1:07 PM) Loop through the bill amounts in reverse order dividing the amount left by the current bill size. From Luke Pollard to Everyone: (1:10 PM) Starting with the highest denomination and check to see if it works and subtract it from the integer number and repeat until it doesn't, go down until the integer number is 0. From Krish Singhvi to Everyone: (1:10 PM) Subtract using the highest currency bill possible and keep going until you have to move to the next one and then keep doing it until there is nothing left. From Sophia Benjamin to Everyone: (1:10 PM) Use as many 100s as you can, then as many 50s, etc (basically what’s already been said) From Paul Warner to Everyone: (1:11 PM) For each denomination, calculate value // denomination. The result is how many bills you need of that value and the remainder is the new value. From Leo Atalla to Everyone: (1:11 PM) I forgot to say to subtract the amount of the bill once you count it in and then use that value for the next iteration
Be greedy!
Binaria
In the land of Binaria, money comes in an infinitude of denominations, which are powers of 2: 1, 2, 4, 8, 16 32, 64, ..... in a currency called a bit. Given an integer number of bits, how do you count out that amount using as few bills as possible?
How succinctly can you write this procedure? Do you need to use any symbols at all?
From Krish Singhvi to Everyone: (1:14 PM) Same thing From Luke Pollard to Everyone: (1:15 PM) 1 256 From Pranet Sharma to Everyone: (1:15 PM) 1x256, 1x128, 1x1 From Sophia Benjamin to Everyone: (1:15 PM) 1 256, 1 128, 1 1 From Leo Atalla to Everyone: (1:15 PM) 110000001 From Dhruv Ranganath to Everyone: (1:15 PM) There will be only one of each type of bill From Luke Pollard to Everyone: (1:15 PM) 1 128 and 1 1 My messages got divided From Carl Pittenger to Everyone: (1:15 PM) 385 - 256 = 129 129 - 128 = 1 1 - 1 = 0 start with 385 Use 1 256 129 Use 1 128 1 Use 0 64 1 Use 0 32 1 Use 0 16 1 Use 0 8 1 Use 0 4 1 Use 0 2 1 Use 1 1 0 385 = 0b110000001 "bigendian"
Base Numbering Systems
Our Wormwoodean System
base numbering alphabet base = size(alphabet) {0,1,2,3,4,5,6,7,8,9} base = 10 Computers understand bitstreams. base 2 numbers rule
Bigendian vs. Littleendian Methods