We all know how to count in decimal, but there are a few things about it that I’d like us to notice before we move on. When we learn to count and particularly to add up numbers, we are taught to make three columns, hundreds, tens and units. In the units column can appear any digit from 0-9. When the number is bigger than that, we put a number in the tens column, and so on.
Binary can have only two possible digits in each column, 0 or 1. So our units column can be zero or one, but then next column along is units of 2 instead of units of 10. So 2 in decimal becomes 10 in binary, 3 decimal is 11 binary, and 4 decimal is 100 binary … hopefully by now you see the pattern! The columns go up in powers of 2 instead of powers of 10.
Binary is interesting because it’s a series of flags – I’ll write another time about bits and shifting and logical operations.
Again, this is all the same idea as before, everything keeps counting but we use a different number of symbols in the units column, and so the next column up has a bigger value. With hex, we can count to 16 rather than 10 – so we use digits 0-9 and then a, b, c, d, e and f to make up to 16. We work with this number system all the time since HTML colours are hexadecimal numbers, so I often think this is the most familiar other system for web developers.
It isn’t unusual to see hex used in calculations, and the trick with this is to write down the columns and concentrate hard. So for example a3 in hex is 163 – because the digit a represents 10, and is in the 16 column, so we have 160, plus the 3 from the units column.
Exactly why octal is included is a mystery to me, I’ve never used it other than to answer ZCE exam questions. Perhaps there’s a useful application that I’m not aware of, in which case I’m interested to hear what that is! In any event, you have the idea by now and octal works in exactly the same way: we can have digits 0-7 in the units column, and the other columns go up in powers of 8:
Number systems are not complicated although depending on your background they may be unfamiliar. My recommendation is to set yourself some simple decimal arithmetic questions (links to examples are appreciated) and then try them in each of the other number systems, to practice working with the different sets of digits. This was a simple explanation but it isn’t rocket science at all, and I hope it was helpful!