Multiply
IIIIII * III = IIIIIIIIIIIIIIIIII
It's easy!!! For each mark in the second make a copy of the first. Glue the copies together. No wormwoodean times tables!
Integer Division and Mod
If you don't know mod (%), it is computed by dividing the right-hand operand into the left and computing the remainder.
8 % 3 = 2
Integer division is division that discards any remainder. Its symbol is //.
8 // 3 = 2
What is the siginificance of 365% 7 = 1
?
Think about your birthday!
So let's do these operations with tally marks.
16 // 5
We now compute
IIIIIIIIIIIIIIII// IIIII1. Make groups of 5.
IIIII IIIII IIIII I
Make one tally mark for each full group.
III
Et Voila! There's your integer quotient.
The remainder is what's left after you make the groups.
IIIIIIIIIIIIIII % IIIII = I
Arithmetic is butt-simple. But visual representaion is awful.
Roman Numerals
M 1000 D 500 C 100 L 50 X 10 V 5 I 1
These borrowing conventions are all of the legal ones.
IX 9 IV 4 XL 40 XC 90 CM 900 CD 400
We convert 298 here.
CC 200 CCXC 290 CCXCV 295 CCXCVIII 298
Here is a little arithmetic.
Decimal Roman 1 298 CCXCVIII 521 DXXI --- ------------- 819 DCCCXVIIII → DCCCXVIXPITA
Arithmetic is awful, but numbers are compact. People known as calculators did calculations as a profession.
Roman numerals are a denominational numbering system.
Another denominational system is US paper currency.
1 2 5 10 20 50 100
You were asked to write down a procedure to count out an integer number of dollars using as few bills as possible.
We discovered the "greedy algorithm." Use as many bills as possible with the largest denomination. Repeat this with each smaller denomination until the amount has been counted out.
Now imagine a country whose "bills" come in denominations that are powers of 2. Let's count out 221 units.
Begin by listing denominations until they are > 221. 1 2 4 8 16 32 64 128 256 In the second colum, you put how many bills you used, and in the third puts what's left. We can't use any 256s. 1 2 4 8 16 32 64 128 256 0 221 We can use a 128 1 2 4 8 16 32 64 128 1 59 256 0 221 We can't use a 64. 1 2 4 8 16 32 64 0 52 128 1 59 256 0 221 Continue up the chain. 1 1 0 2 1 1 4 0 3 8 1 3 16 1 11 32 1 27 64 0 52 128 1 59 256 0 221
Observe that you never use more than one bill of any
denomination. Read up the middle column and you will see
the binary representation of 221: 0b10111011
.
The 0b
prefix says, "this is a binary number."
This works for any base. Let's try 3.
We turned it upside down. Now read up the down the middle column.
243 0 243 81 2 59 27 2 5 9 0 5 3 1 2 1 2 0
221 = 220123.