(Already covered in F.Y.)
Sample Example from our school days
1234=1000 + 200 + 30 + 4
=1*1000 + 2 * 100 + 3 * 10 + 4 * 1
=1 * 10^3 + 2 * 10 ^2 + 3 * 10^1 + 4 * 10^0
Why 10 is so important ? Why we are not skipping 10 with its power anywhere ? Why only 10 ?
The answer is we are using DECIMAL number system. it has 10 symbols 0 to 9, hence 10 is so important.
There are other number systems also like binary, octal , hexadecimal.
Binary
- Binary has 2 symbols (0 and 1).
- Any binary number will be composed of only 0 and 1. If you see other symbols in binary number then it is either mistake or its not a binary number.
- Like 10 in Decimal System, We will use 2 in binary number system to interpret the number
- 101 in binary = 1*2^2 + 0*2^1 +1*2^0
Octal
- Has 8 symbols (0 to 7).
- Any binary number will be composed of 0,1,2,3,4,5,6,7 (Not 8). If you see other symbols in Octal number then it is either mistake or its not an Octal number.
- Like 10 in Decimal System, We will use 8 in Octal number system to interpret the number
- 742 in binary = 7*8^2 + 4*8^1 +2*8^0
Hexadecimal
- Has 16 symbols (0 to 9 and A=10,B=11,C=12,D=13,E=14,F=15).
- Any Hexadecimal number will be composed of above symbols.
- Like 10 in Decimal System, We will use 16 in Hexadecimal number system to interpret the number
- 7BA in binary = 7*16^2 + 11*16^1 +10*16^0
Specifying Number system
We use decimal number system so we don't specify it. But in Computer Science using number without specifying number system is confusing for the reader.
Ex. 10 , it can be binary, octal ,decimal or hexadecimal
Ex. 12 , it can be octal, decimal or hexadecimal
Ex. 18 , it can be decimal or hexadecimal
To avoid such confusions we need to Specify number system as a subscript
2/b/B for Binary
8/o/O for Octal (try to avoid use of 'o' or 'O', it looks similar to '0')
10/d/D for Decimal
16/h/H for hexadecimal