3.3.2 - Converting between number bases
Convert whole numbers between decimal, eight-bit binary and hexadecimal, using place values and four-bit groups. The examined decimal range is 0–255.
Binary and decimal conversion
Each binary position contributes its place value when its bit is 1 and contributes zero when its bit is 0.
For eight bits, write the headings before working:
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Binary 10110110 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 |
Add only the selected columns: . Thus binary 10110110 is decimal 182. The rightmost bit is worth 1, not 2.
To convert decimal 93 to binary, work from the largest place value down. 128 does not fit, so write 0. 64 fits, leaving 29. 32 does not fit. 16 fits, leaving 13; 8 fits, leaving 5; 4 fits, leaving 1; 2 does not fit; 1 fits, leaving 0. The answer is 01011101. Check it by adding .
Leading zeros do not change a whole number's value. However, keep all eight positions when asked for an eight-bit answer: 00000101 and 101 both represent 5, but only the first has eight bits. Zero is 00000000. The greatest unsigned eight-bit value is .
Hexadecimal and decimal conversion
For values from 0 to 255, hexadecimal needs at most two digits: the left digit counts sixteens and the right digit counts ones.
Use the digit values A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. Hexadecimal B7 represents . Hexadecimal 2F represents . The digit F is fifteen ones, not sixteen.
Continue this lesson.
You’re previewing NovaLearn without an account. Create a free account to read the rest.
Create free account