Number System

Number System Introduction

A brief intro
Different types of numeral system in the world Source: wikimedia.org

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 Notation

The standard of counting since ancient civilization

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
8 10 ... 3 <-- divide 83 by 8, we get 10 and 3 is the remainder
8   1 ... 2 <-- divide 10 by 8, we get 1 and 2 is the remainder
      0 ... 1

* 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
16   5 ... 3 <-- divide 83 by 16, we get 5 and 3 is the remainder
        0 ... 5

* 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
2 41 ... 1 <-- divide 83 by 2, we get 41 and 1 is the remainder
2 20 ... 1 <-- divide 41 by 2, we get 20 and 1 is the remainder
2 10 ... 0 <-- divide 20 by 2, we get 10 and 0 is the remainder
2   5 ... 0 <-- divide 10 by 2, we get 5 and 0 is the remainder
2   2 ... 1 <-- divide 5 by 2, we get 2 and 1 is the remainder
2   1 ... 0 <-- divide 2 by 2, we get 1 and 0 is the remainder
      0 ... 1

* Note: Read the remainder upward, the result is 10100112.

Think reversely, 10100112 = 1x26 + 0x25 + 1x24 + 0x23 + 0x22 + 1x21 + 1x20= 8310

Reference:
Decimal

Octal Notation

A more human-friendly representation of the binary number

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 = 001
2 = 010
3 = 011

The 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

Hex Notation

A more human-friendly representation of the binary number ( Most popular )

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
11 0001
22 0010
33 0011
44 0100
55 0101
66 0110
77 0111
88 1000
99 1001
A10 1010
B11 1011
C12 1100
D13 1101
E14 1110
F15 1111

Example, convert 5316 to base 2

5 = 0101
3 = 0011

The 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 -> 3BA16

Reference:
Hexadecimal

Binary Notation

The standard of modern computer computation

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 -> 16728

Convert base 2 to base 16

Example, convert 111011101016 to base 2

1110111010 -> 0011 1011 1010 -> 3BA16

Reference:
Decimal

About

Contact us

New uploads

Facebook Fans Page

Follow us

Facebook Fans Page
Terms | Privacy Policy

© dec2hex.com 2017-2024