In order to convert decimals to binaries, we reverse the process outlined in Section G.1 for converting a binary to a decimal.
4110 = | 20x2 | + 1 | Dividing 41 by 2, gives the quotient 20 and remainder 1. |
2010 = | 10x2 | + 0 | We again divide the current quotient 20 by 2. |
1010 = | 5x2 | + 0 | |
510 = | 2x2 | + 1 | We repeat this procedure until ... |
210 = | 1x2 | + 0 | |
110 = | 0x2 | + 1 | ... the quotient is 0. |
4110 = | 1010012 |
The divisor used in the steps above is the base of the target number system (binary, base 2). The binary value, 1010012, is represented by the remainders, with the last remainder as the left-most bit. Back substitution of the quotient gives the same result:
4110 | = (((((0x2 + 1)x2 + 0)x2 + 1)x2 + 0)x2 + 0)x2 + 1 |
= 1x25 + 0x24 + 1x23 + 0x22 + 0x21+ 1x20 | |
= 1010012 |
Analogously, we can apply the above procedure for converting an octal to a binary. The conversion for the decimal number 90 can be done as follows:
9010 = | 11x8 | + 2 |
1110 = | 1x8 | + 3 |
110 = | 0x8 | + 1 |
9010 = | 1328 = 0132 |
The remainder values represent the digits in the equivalent octal number: 1328. This can be verified by back substitution, which gives the following result:
9010 | = ((0x8 + 1)x8 + 3)x8 + 2 |
= 1x82 + 3x81 + 2x80 | |
= 1328 = 0132 |
Conversion to hexadecimal is analogous:
9010 = | 5x16 | + 10 |
510 = | 0x16 | + 5 |
9010 = | 5a16 = 0x5a |
The remainders represent the digits of the number in the hexadecimal system: 5a. Back substitution gives the same result:
9010 | = (0x16+ 5)x16 +10 |
= 5x161 + ax160 | |
= 5a16 = 0x5a |