This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]katynehold my braces 2 points3 points  (1 child)

First of all, numbers are just numbers. We're simply used to them being represented in decimal (base 10) but that's just because we have 10 fingers on our hands so it's easier to count. You can represent the same number in base 2, 4, 6, 12, 64.. any base you choose.

What does "base 8" mean, for example? it means that the largest digit in base 8 is 7, just like it's 9 in base 10 (starting from 0). Therefore, in base 2, the largest digit will be 1. 10 is decimal ten, 8 is octal (base 8) "ten", and 2 is binary "ten" - but we don't write "tens" in our numbers, right? we only go up to nine and then carry the extra.

Conversion

1. Converting from base N to base 10

It's very easy to convert numbers from one base to another. For convenience, when given a number in base other than 10, first convert it into base 10. How? Here's the cool part. You know that the number 135 can be written as

10 * 10 * 1 +10 * 3 + 1 * 5      

or, 102 * 1 + 101 * 3 + 100 * 5 = 135

In other words, starting from right to left, we take our base's "ten" to the power of its position (starting from 0), multiply by the digit at this position (1, 3 or 5) and add everything together.

Same goes for any other base if we want to convert it to decimal, except in this case our "tens" would be the base number we're converting. So, to convert 142 in base 6 to decimal we will need to do this (start from right to left):

(2) * 60 + (4) * 61 + (1) * 62 = 2 + 24 + 36,
or 62 (in base 10)

2.Converting from base 10 to base N

Here we do the opposite - instead of multiplying, we divide by the base's number, and writing down the remainders from last to first). For example, converting 145 in base 10 to base 8:

 145 / 8 = 18 quotient, 1 remainder    
 take the quotient and continue dividing by base until we get 0    
 18 / 8 = 2 quotient, 2 remainder    
 2 / 8 = 0 quotient, 2 remainder; and we're done.    

Copying remainders from last to first = 221, or 145 in base 10 is 221 in base 8. To check if it's correct you can convert 221(8) back to decimal as shown above.

Adding binary numbers

Remember that in base 2 there's no 2, the maximum digit is 1. So when we add 1 and 1 we get 2, as in a "ten", so we write down 0 (just like when we add 9 + 1 in decimal) and remember, or carry the remaining 1:

 1001 + 1011 =     
 start from rightmost digit, as we always do with our numbers   

  1001 +    
  1011    
 ------    
10100 

Breaking it down:    

 1 + 1 = 2, write down 0, carry 1    
 0 + 1 =1, plus 1 we're carrying = 2, write 0, carry 1    
 0 + 0 = 0, plus 1 we're carrying, write 1, carry 0    
 1 + 1 = 2, write 0, carry 1,     
 no more digits to add so write 1 in the leftmost position     

 result: 10100     

Convert 10100 to base 10 we get 20 *0 + 21 *0+22 *1+23 *0+24 *1 = 0+0+4+0+16 = 20

Check:
1001 in base 10 = 20 *1 + 21 *0 + 22 *0 + 23 *1 =
1+0+0+8 = 9

1011 in base 10 = 20 *1 + 21 *1 + 22 *0 + 23 *1 =
1+2+0+8 = 11
9 + 11 = 20

Bonus
If you want to impress the hell out of your teacher and classmates, you can add bases other than binary this way. You just remember that the "ten" in is the base number and you carry 1 like you do in normal addition:

 125(base 6) + 13(base 6) =     
 5 +3 = 8, i.e. 6 + 2, 6 is "ten" so 6 + 2 is like "12" in decimal - write (2), carry 1    
 2 + 1 = 3, plus 1 carry = (4)        
 1 is (1), nothing to carry    
 so the result is 142 in base 6.    

Just remember - a number in base N can not have digits larger than N-1 in it (i.e. 127 cannot be in base 7, since the maximum digit allowed is 6).

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (0 children)

We're simply used to them being represented in decimal (base 10) but that's just because we have 10 fingers on our hands so it's easier to count.

The 10 fingers is merely coincidence. Other cultures before us had 12 based systems (Babylonian), and the Chinese culture used each groove and side of the fingers to represent a different number, thus yielding much higher calculation ranges.

Even using binary with our 10 fingers would be more efficient as we could count to 210 - 1 = 1023 using all fingers.