Week 4 · Chapter 6 Information Design (1): analog and digital, binary and the amount of information, hexadecimal, digital representation of characters · 3 lessons
2
Counting in two and in sixteen
ICT Secondary 1 Term 1, Chapter 6, Lessons 6-1 to 6-4: pp. 53–64
GoalConvert between binary, decimal and hexadecimal by place values and by groups of four bits.
New words
binary · the number system with only the digits 0 and 1place value · what a digit is worth because of its positionhexadecimal · the base-16 system with digits 0–9 and A–Fdecimal · the everyday base-10 system
Explanation
In decimal each place is worth ten times the place on its right. In binary each place is worth two times the place on its right, so the places of 8 bits are 128, 64, 32, 16, 8, 4, 2, 1. To read a binary number, add the place values where the digit is 1: 1011 0101 is 128 + 32 + 16 + 4 + 1 = 181. To write a decimal number in binary, divide by 2 again and again and keep the remainders; read them from the last to the first. For 37: 37 ÷ 2 = 18 remainder 1, 18 ÷ 2 = 9 r 0, 9 ÷ 2 = 4 r 1, 4 ÷ 2 = 2 r 0, 2 ÷ 2 = 1 r 0, 1 ÷ 2 = 0 r 1; reading upward gives 100101. Binary numbers get long, so people use hexadecimal, which has 16 digits: 0 to 9 and then A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. One hex digit stands for exactly four bits. To convert, cut the bits into groups of four, starting at the right-hand end: 1010 0111 is A and 7, so A7. Check: A7 = 10 × 16 + 7 = 167, and 1010 0111 = 128 + 32 + 4 + 2 + 1 = 167. The biggest byte, 1111 1111, is FF = 255. Colour codes on web pages are written in hex.
Place value
128
64
32
16
8
4
2
1
1011 0101
1
0
1
1
0
1
0
1
worth
128
32
16
4
1
Worked examples
Division
Quotient
Remainder
37 ÷ 2
18
1
18 ÷ 2
9
0
9 ÷ 2
4
1
4 ÷ 2
2
0
2 ÷ 2
1
0
1 ÷ 2
0
1
Convert decimal 37 to binary by division by 2. The remainders, read upward, are 1, 0, 0, 1, 0, 1. Check by place values: 32 + 4 + 1 = 37.
Hex
Bits
Hex
Bits
0
0000
8
1000
1
0001
9
1001
2
0010
A
1010
3
0011
B
1011
4
0100
C
1100
5
0101
D
1101
6
0110
E
1110
7
0111
F
1111
Hex and binary go together by groups of four. The table lists each hex digit with its four bits. Convert 2F to binary: 2 is 0010 and F is 1111, so 2F is 0010 1111 = 47.
Class activity
Without a device, convert these: decimal 20 to binary; binary 0110 1001 to decimal and to hex; hex 3C to binary. Check each answer by converting it back.
Practice
1
Convert binary 1010 to decimal.
8 + 2 = 10.
2
Convert decimal 11 to binary.
1011 (8 + 2 + 1 = 11).
3
Convert hex 2D to decimal.
2 × 16 + 13 = 45.
4
Why do people use hexadecimal when computers work in binary?
A hex number is four times shorter and easy to convert, because each hex digit stands for exactly four bits.