|
| |||||||||||||
|
|||||||||||||
|
BasesThe numbers you are most probably used to seeing are decimal numbers,
those in base 10 (unless you're a life long computer programmer and can
only work in hexadecimal and binary). For example, in base 10 you need 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 which is 10 digits. So if our base was 2 (binary) we would need 2 digits, 0 and 1. In base 10 (decimal) the different levels are powers of 10 (see also powers and roots, and scientific notation): 100, 101, 102, 103, 104 etc (anything to the power zero is 1) and 10-1, 10-2, 10-3 etc So when we write 100 what we mean is: (1 x 102) + (0 x 101) + (0 x 100) and 456 = (4 x 102) + (5 x 101) + (6 x 100) In base 16 (hexadecimal) 456 = (4 x 162) + (5 x 161) + (6 x 100) certainly a different quantity. So make sure there's no confusion about bases. Binary and hexadecimal are the ones you are most likely to encounter, other than decimal. Even then, that's only true if you are studying computing or communications in any depth. How do you get between bases (and we're not talking rounders or softball here).
From binary (or any other base) to decimal is fairly straightforward. Write the number as its full sum of powers of 2 (or whatever) and then calculate the result of the expression. For example: 101101 = (1x25) + (0x24) + (1x23) + (1x22) + (0x21) + (1x20) = (1x32) + (0x16) + (1x8) + (1x4) + (0x2) + (1x1) = 32 + 8 + 4 + 1 = 45 (base 10)
Going from decimal to binary (or any other base) is slightly more intricate.
Start with the greatest power of 2 that is less than (or equal to) the
number you have. Let's say that number is n. Write down 1x2n.
Subtract that from your first number. Now start the process again with
that new number and continue until you are left with no remainders. Now
fill the gaps between the powers with 0x2missing powers, if
you haven't already. That expression will then give you the sequence of
1s and 0s for your number in base 2. The biggest power of 2 less than 89 is 64 which is 1x26 89-64 = 25 The next lowest power is 32, but that is bigger than 25 so we have 0x25 The next lowest power is 16, which is less than our number, so we have 1x24 leaving 25-16 = 9 8 is in there too, so we have 1x23 to add to our expression and leaves us with 9 -8 = 1 22 isn't, nor is 21 but 20 (=1) is, and that leaves nothing, so we've finished. Writing down everything from above we have: (1x26) + (0x25) + (1x24) + (1x23) + (0x22) + (0x21) + (1x20) and so 1011001 (base 2) = 89 (base 10). The same process will convert decimal to any other base, but clearly in other bases you may have to have a number other than 1 or 0 multiplying your power of the base number. For example 32 in base 10 is 2x161, so: 32 (base 10) = 20 (base 16) Note also that in bases greater than 10, you'll need more symbols for digits than you are used to. There is already a convention for this, and in base 16, for example, the 16 digits required for each power of 16 are 0-9,A-F. So, F (base 16) = 15 (base 10), and AC (base 16) = 172 (base 10). Have a go at the Quiz! |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||