Ancient civilizations invented different types of symbols to represent number and grouping. Many of them use decimal ( base-ten ) representation, probably because there are ten fingers on two hands. :)
Among all ancient civilizations, Chinese numeral system was the most sophisticated and advanced. Evidence of using decimal number was found in an inscription from the ancient time, which date back to at least the 2nd millennium BCE.
In additional to base 10 system, there are other numeral systems, such as base 60, which was also commonly used by ancient people for date time calculation. In modern time, computers use the binary numeral system for internal calculation. Hexadecimal and octal are the companion for the binary number as they are easy to use.
Reference:
Numerals from Ancient China
The Story of Mathematics
Decimal, also called the base-ten positional numeral system or denary, or Hindu–Arabic numeral system, has 10 symbols ( 0123456789 ).
Number position and value
Number | 10 Thousands | Thousands | Hundreds | Tens | One |
---|---|---|---|---|---|
10 = | 1x101 + | 0x100 | |||
100 = | 1x102 + | 0x101 + | 0x100 | ||
1234 = | 1x103 + | 2x102 + | 3x101 + | 4x100 | |
12345 = | 1x104 + | 2x103 + | 3x102 + | 4x101 + | 5x100 |
From the above examples, we can observe that the value of each position represents a specific power of the base 10. The above concept is the key to understand the number value in different base notation, and convert them back to decimal value. We will discuss base x to base 10 conversion in next sections.
Convert base 10 to base 8
To fit a base 10 into a base 8 number, the resulting number will be "longer". We can use the successive division-remainder method to achieve the conversion. That is, we divide our target number continuously by 8, until we get all the remainders. On each division, we shift 1 position and the value of the resulting remainder increase by 8position-1
Example, convert 8310 to base 8
8 83* Note: Read the remainder upward, the result is 1238.
Think reversely, 1238 = 1x82 + 2x81 + 3x80 = 8310
Convert base 10 to base 16
To fit a base 10 into a base 16 number, the resulting number will be "shorter". We can use the successive division-remainder method to achieve the conversion. That is, we divide our target number continuously by 16, until we get all the remainders. On each division, we shift 1 position and the value of the resulting remainder increase by 16position-1
Example, convert 8310 to base 16
16 83* Note: Read the remainder upward, the result is 5316.
Think reversely, 5316 = 5x161 + 3x160 = 8310
Convert base 10 to base 2
To fit a base 10 into a base 2 number, the resulting number will be "longer". We can use the successive division-remainder method to achieve the conversion. That is, we divide our target number continuously by 2, until we get all the remainders. On each division, we shift 1 position and the value of the resulting remainder increase by 2position-1
Example, convert 8310 to base 2
2 83* Note: Read the remainder upward, the result is 10100112.
Think reversely, 10100112 = 1x26 + 0x25 + 1x24 + 0x23 + 0x22 + 1x21 + 1x20= 8310
Reference:
Decimal
Octal, also called base 8, has 8 symbols ( 01234567 ). Oct is a more human-friendly representation of the binary number, each oct digit represents 3 binary digits. Oct was commonly used with old computers which employed 12-bit, 24-bit or 36-bit words. Similar with the decimal number, the value of an octal digit is determined by the position of the symbol in the number.
Number position and value
Number | 83 | 82 | 81 | 80 |
---|---|---|---|---|
128 = 1010 = | 1x81 + | 2x80 | ||
1238 = 8310 = | 1x82 + | 2x81 + | 3x80 | |
12348 = 66810 = | 1x83 + | 2x82 + | 3x81 + | 4x80 |
From the above examples, we can observe that the value of each position represents a specific power of the base 8. After adding all the values together, we get the value of the octal in base 10. That is how we convert a number from base 8 to base 10 :)
Convert base 8 to base 2
To convert a base 8 to binary, we can first convert it to a decimal number and then to the binary by the successive division-remainder method. However, this is the difficult way and it is not preferred. Consider Oct is actually a binary companion, and each oct represents 3 binary digits, binary conversion is actually very easy.
Octal Digit | Binary Value |
---|---|
0 | 000 |
1 | 001 |
2 | 010 |
3 | 011 |
4 | 100 |
5 | 101 |
6 | 110 |
7 | 111 |
Example, convert 1238 to base 2
1 = 001The digit value and position is an exact 1-to-1 match, so we only need to concatenate the all the binary digits together. The result is 001 010 0112 or 10100112 ( preceding zero removed )
Convert base 2 to base 8
Similarly, just perform the operation in the reverse. First group binary digits into 3, then you can convert each group to an Oct digit. Finally, concatenate all the oct digits.Reference:
Octal
Hexadecimal, also called base 16 or hex, has 16 symbols ( 0123456789ABCDEF ). Hex is a more human-friendly representation of the binary number, each hex digit represents 4 binary digits, 2 hex digits represents 1 byte( 8 binary digits ).
Hex is used with almost all modern computers as it is most efficient and easy way to represent 1 byte. Similar with the decimal number, the value of a hex digit is determined by the position of the symbol in the number.
Number position and value
Number | 163 | 162 | 161 | 160 |
---|---|---|---|---|
1216 = 1810 = | 1x161 + | 2x160 | ||
12316 = 29110 = | 1x162 + | 2x161 + | 3x160 | |
123416 = 466010 = | 1x163 + | 2x162 + | 3x161 + | 4x160 |
From the above examples, we can observe that the value of each position represents a specific power of the base 16. After adding all the values together, we get the value of the hex in base 10. That is how we convert a number from base 16 to base 10 :)
Convert base 16 to base 2
To convert a base 16 to binary, we can first convert it to a decimal number and then to the binary by the successive division-remainder method. However, this is the difficult way and it is not preferred. Consider hex is actually a binary companion, and each hex represents 4 binary digits, binary conversion is actually very easy.
Hex Digit | Decimal Value | Binary Value |
---|---|---|
0 | 0 | 0000 |
1 | 1 | 0001 |
2 | 2 | 0010 |
3 | 3 | 0011 |
4 | 4 | 0100 |
5 | 5 | 0101 |
6 | 6 | 0110 |
7 | 7 | 0111 |
8 | 8 | 1000 |
9 | 9 | 1001 |
A | 10 | 1010 |
B | 11 | 1011 |
C | 12 | 1100 |
D | 13 | 1101 |
E | 14 | 1110 |
F | 15 | 1111 |
Example, convert 5316 to base 2
5 = 0101The digit value and position is an exact 1-to-1 match, so we only need to concatenate the all the binary digits together. The result is 0101 00112 or 10100112 ( preceding zero removed )
Convert base 2 to base 16
Similarly, just perform the operation in the reverse. First group binary digits into 4, then you can convert each group to a hex digit. Finally, concatenate all the hex digits.Example, convert 111011101016 to base 2
1110111010 -> 0011 1011 1010 -> 3BA16Reference:
Hexadecimal
The modern binary number system was invented by Gottfried Leibniz in 1689 influenced by ancient Chinese literature. Binary number is a number expressed in the base-2 numeral system 0 and 1, used by almost all modern computer-based devices.
Some very early computers did not use binary for computation, for example, the ENIAC used decimal instead. However, due to the simplicity and reliability of binary logic design, almost all modern computers nowadays use binary coding system. Similar with decimal number, the value of a hex digit is determined by the position of the symbol in the number.
Number position and value
Number | 23 | 22 | 21 | 20 |
---|---|---|---|---|
102 = 210 = | 1x21 + | 0x20 | ||
1002 = 410 = | 1x22 + | 0x21 + | 0x20 | |
10102 = 1010 = | 1x23 + | 0x22 + | 1x21 + | 0x20 |
From the above examples, we can observe that the value of each position represents a specific power of the base 2. After adding all the values together, we get the value of the binary in base 10. That is how we convert a number from base 2 to base 10 :)
Due to the special relationship with oct and hex, converting binary to oct or hex is very easy.
Convert base 2 to base 8
Example, convert 11101110108 to base 2
1110111010 -> 001 110 111 010 -> 16728Convert base 2 to base 16
Example, convert 111011101016 to base 2
1110111010 -> 0011 1011 1010 -> 3BA16Reference:
Decimal
© dec2hex.com 2017-2024