Friday, February 09, 2018

Number systems

Recap counting!

Source: wikimedia.org
The decimal number system that we are used to, is called so because it uses 10 distinct symbols to represent any value. These symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Any ‘number’ can therefore be represented by combining these 10 distinct symbols.
What is interesting is that, this is not the only way to represent the numbers. I mean, one could imagine a system where instead of symbols 0->9 one used alphabet a->h. So 24 could be written as ce. It is funny, but is perfectly possible. Since most of us are taught to count in decimals right from the time we were kids, and since we usually have ten fingers, this manner of counting seems ‘natural’ to us ๐Ÿ˜Š. (The Octopus, I’m sure, has an octal (base 8) number system ;p)
Octopus. Source: https://commons.wikimedia.org/wiki/File:Octopus_pallidus.jpg
Another variation would be, if there were 16 symbols instead of just 10! This is exactly what the hexadecimal system does, it has symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f. So, Bryan Adams was singing ’18 till I die’ in a hexadecimal world, he would sing: ’hex one zero till I die’. I hope you get the drift.
The number of symbols available in the system for representing a value is called its ‘base’. So decimal numbers have base 10. Hexadecimal numbers have a base 16.
In a similar fashion, in the binary world, there are unfortunately only two symbols 0 and 1 (and they correspond beautifully into one of the simpler natures of electricity that either flows/ ON state/ 1 or does not/ OFF state/ 0) (or, has the potential to flow or not ๐Ÿ˜‰). So binary numbers are base 2.
Numbers with a particular base are written as a subscript: (X)n
When we deal with decimals or places where the n is obvious, we of course ignore writing it.
Bonus: Here is a link to a simple C program to convert between bases: http://www.geeksforgeeks.org/convert-base-decimal-vice-versa/
Hope you know your numbers better now ๐Ÿ˜Š

No comments: