Number Systems
Part 1: Number systems and their decimal equivalents
A numbering system or number system is a system that represents numbers in a unique manner using a particular set of symbols. For instance, the decimal system is a number system based on number 10, which is called the base or basis of the system. If n is the base of a number system, then there are n different single symbols in a range of 0 to (n-1) representing numbers in that system. Common number systems are decimal (base 10), binary (base 2), hexadecimal (base 16), and octal (base 8).
A. The decimal number System (Base-10 Number System)
For decimal system, the symbols (or digits) used to represent numbers in the system are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, for example, number 526 or number 526.38.
In the decimal system, number 526 can be expressed as
or
Note that the meaning and position of each digit (in red) in number 526 are defined by its respective term on the right hand side (RHS) of Eq. (A.1), whereas the base is in blue color.
Similarly, number 526.38 can be expressed as
or
Again, note that the meaning and position of each digit in number 526.38 are defined by its respective term on the RHS of Eq. (A.2), and also note that digits following the decimal point (i.e., 3, 8) have negative sign in its exponent term on the RHS.
B. The binary number system (Base-2 Number System)
For binary system, because the base is 2, only digits 0 and 1 can be used to represent the numbers. Numbers 1101 and 1101.01 are two examples of binary numbers. Similar to Eq. (A.1), but with the base is now 2 instead of 10, binary number 1101 can be written as
which in decimal system means
or
Therefore, binary number 1101 has a value of 13 in the decimal system.
Similar to Eq. A.2, but with the base of 2, binary number 1101.01 can be expressed as
which in the decimal system means
or
or
Therefore, binary number 1101.01 has a decimal value of 13.25.
C. The hexadecimal number system (Base-16)
For hexadecimal system, as the base is 16, there are 16 symbols (or digits) to be used to represent the numbers in this system, they are 0 to 9 and then A, B, C, D, E, F (not case-sensitive). Symbols A, B, C, D, E, F are used to replace 10, 11, 12, 13, 14, 15, respectively, because only single digit/symbol can be used. For instance, A1E and A1E.2D are two examples of hexadecimal numbers. Equivalent of A1E in the decimal system is:
substitute A with 10 and E with 14, we have
or
and the equivalent of A1E.2D in the decimal system is:
or
or
Therefore, equivalent numbers of A1E and A1E.2D in the decimal system are 2590 and 2590.175781, respectively.
D. The Octal number system (Base-8 number system)
Octal system has the base of 8. There are 8 digits, 0, 1, 2, 3, 4, 5, 6, 7, to be used to represent the numbers in this system. Conversion of an octal number to decimal number is carried out in the same way as for binary or hexadecimal numbers. For instance, two octal numbers 725 and 725.36 can be converted to decimal numbers as follows:
E. Other number systems
Theoretically, any number can be used as a base for a numbering system, and conversion of any number of any base to its equivalent decimal number follows the same method as described by Eqs A.1, A.2 or B.1, B.2 above. For example, using the described approach, quaternary numbers (base 4 numbers) 2103 and 2103.12 are found having decimal values of 147 and 147.375, respectively.
Example
Question: In which system is the number ‘101’ equivalent to a decimal 50?
Answer: Let x be the unknown base and x > 0, similar to Eq. A.1, we can write
The base is 7, thus, the system is septenary system.
Notes:
- For fractional numbers, the fractional part could be infinite, so, if you want to limit the number of digits after the decimal point, a cut-off may be needed. In such cases, the number and its equivalent decimal value may not be exactly equal.
- Conversion of a decimal number to another number system is covered in Number Systems, Part 2
- In general, a number can be converted to any other number system by using the decimal system as an intermediate step. A Python code for converting a number of any base to another number system can be found here. In this code, the base is only between 2 and 16, but users can expand it for any base greater than 16, if a system of symbols is defined for such a base accordingly.