☰ خطة العام · تكنولوجيا المعلومات والاتصالات (بالإنجليزية)

Binary, bits and bytes

الأسبوع 2 · الوحدة ١ «النظم العددية» (٢): لماذا يستخدم الكمبيوتر النظام الثنائي، الخانة الثنائية والبايت، عدد الاحتمالات الثنائية · 3 دروس
3

How many patterns can n bits make?

ICT Secondary 3 Term 1, Unit 1, Topic 1: pp. 11–13
GoalUse 2ⁿ to count the patterns of n bits and to find how many bits a menu needs.
New words
pattern · one particular row of 0s and 1spower of two · 2 multiplied by itself some number of times, for example 2³ = 2 × 2 × 2 = 8doubling · multiplying by 2
Explanation

One bit can be 0 or 1, so it makes 2 patterns. Two bits make 4 patterns: 00, 01, 10 and 11. Three bits make 8. Each extra bit doubles the number of patterns, because we can put a 0 or a 1 in front of every old pattern. So n bits make 2ⁿ patterns, where 2ⁿ means 2 multiplied by itself n times. One byte, 8 bits, makes 2⁸ = 256 patterns, enough for the numbers 0 to 255. To find how many bits a menu needs, look for the smallest n for which 2ⁿ is at least the number of choices. Five choices need 3 bits, because 2² = 4 is too small and 2³ = 8 is enough.

Bits nPatterns 2ⁿ
12
24
38
416
532
664
7128
8256
101024
Worked examples
ABC
000
001
010
011
100
101
110
111
List all patterns of three bits. Write the four patterns of two bits, put a 0 in front of each of them, then write them again with a 1 in front. That gives 4 + 4 = 8 rows, which is 2³.
BitsPatternsEnough for 6 choices?
24no
38yes
A game menu has 6 choices. Two bits give 2² = 4 patterns, which are too few. Three bits give 2³ = 8 patterns, which are enough. So 3 bits are needed and two patterns stay unused.
Class activity

Write on paper the 16 patterns of four bits in the order 0000, 0001, 0010 and so on. Check that you have 2⁴ patterns and that the first eight begin with 0 and the last eight begin with 1.

Practice
1
How many patterns can 6 bits make?
2
What is the smallest number of bits that gives a different pattern to each of 20 choices?
3
How many patterns does a byte make, and why?
4
A pattern of 7 bits is made one bit longer. How many patterns are there before and after?
5
How many bits are enough to give a different pattern to the answers “yes” and “no”?