# What is a numeral system?

Programming Answer

Click here to type your answer

Safarov answered

Numeral system is representing numbers with certain rules. Mainly used Numeral systems are decimal (base 10), binary (base 2), hexadecimal (base 16). You can have numeral system of any base. Here is some examples,  10 ( decimal ) , 1010 (binary), A (hexadecimal - base 16).

Each numeral system has it's base number,  you can't use digits bigger than base in that numeral system. For example for binary system base is 2, it means you can use only 0 and 1 to represent numbers. In decimal system you can use all digits 0, 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9.  For hexadecimal (16) we should add missing digits  "A" - for decimal 10,  "B" - for decimal 11, "C" - for decimal 12, "D" - for decimal 13, "E" - for decimal 14, "F" - for decimal 15.  As we can use up to 16, we don't need letter for 16.

Converting numerical system is easy,  to convert any base to decimal (base 10) you will need to calculate base values first.

For example for 1010 in binary system,  you are doing following steps:  1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 = 8 + 0 + 2 + 0 = 10 . It means 1010 in binary makes 10 in decimal representation. As you can see, we calculate first base value for each position, for example first base value of position 3 is 8 , as 23 makes 8, for second position 2 - 22 make 4 ... so on.  Until we get first digit from right with position 0,  any number with power 0 makes 1 as we know from algebra.

Here another example to convert hexadecimal number to decimal :  "AF"  in hexadecimal makes A x 161 + F x 160  = 10 x 16 + 15 x 1 = 175

Similarly to convert any base number to decimal you will need to keep track of remainders. For example let's convert 10 in decimal back to binary, we just need to divide decimal number to  2 (binary has base 2) and write down remainder until result of division is zero.

10 / 2 = makes 5  remainder is 0  (0th position)

5 / 2 = makes 2 remainder is 1 (1st position)

2 / 2 makes 1 remainder is 0 (2nd position)

1 / 2 makes 0 remainder is 1  (3rd position)  // result of division is 0 and we have a result

So result is  1010 ( 3rd, 2nd, 1st, 0th respectively) 0 points