Decimal numbers are what humans use, and computers use binary. So how does one convert a decimal number to a binary number?
DECIMAL to BINARY Conversion
When converting from decimal to binary the mathematical way is simplest. Start with the decimal number you want to convert and start dividing that number by two, keeping track of the remainder after each complete division. Every time you divide by two, you will divide evenly (0) or get a remainder of one (1). Following the pattern to the end, you will get a binary number. Write the remainders in the order they were generated from right to left and the result is the equivalent binary value.
Example: Convert decimal 44 to binary.
- DIVIDE
44 / 2 = 22 remainder = 0 22 / 2 = 11 remainder = 0 11 / 2 = 5 remainder = 1 5 / 2 = 2 remainder = 1 2 / 2 = 1 remainder = 0 1 / 2 = 0 remainder = 1
- REVERSE THE ORDER OF REMAINDERS The bits, in the order they were generated is 001101 Reversing the order of bits we get 101100. Properly padded with leading zeroes to fill out one byte, we get 01011000
BINARY to DECIMAL
Each binary column has a corresponding decimal value. You can add the decimal values of all columns that have a '1' in them and you will get the decimal equivalent.
Equivalents | COLUMNS | TOTAL | |||||||
Powers of 2 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | |
Decimal | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
BIT VALUES |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 2 + 1 = 3 | |
0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 8 + 4 + 2 = 14 | |
1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 128 + 32 + 8 + 4 = 172 |
<< < 1 | 2 | 3 | 4 | 5 | 6 | 7 > >>