☰ Contents · Computing

Converting between number systems

Lessons 7–8 · 2 lessons · B. Boltayev, M. Mahkamov, A. Azamatov, S. Rahmonqulova. Informatics and Information Technologies, Grade 7. Revised and expanded third edition. “O‘zbekiston milliy ensiklopediyasi” State Scientific Publishing House, Tashkent, 2017
7

Writing numbers of one system in another system

Textbook: pp. 32–34
GoalConverts a number from any positional system to decimal and from decimal to any base, uses the decimal system as a “bridge”, and uses the dyad, triad and tetrad tables between bases 2, 8 and 16.
New words
conversion: writing the same number in another number system · o‘tkazishdivision with remainder: dividing and keeping the remainder · qoldiqli bo‘lishtriad: a group of 3 binary digits standing for one octal digit · triadatetrad: a group of 4 binary digits standing for one hexadecimal digit · tetrada
Explanation

To convert a number from a system whose base is not 10 into decimal, write it in expanded form and compute the sum: 111010₂ = 1 · 2⁵ + 1 · 2⁴ + 1 · 2³ + 0 · 2² + 1 · 2¹ + 0 · 2⁰ = 32 + 16 + 8 + 2 = 58. To convert a whole decimal number into base p, divide it by p with remainder, divide the quotient by p again, and go on until the quotient is less than p. The last quotient and all the remainders (starting from the last, i.e. from bottom to top) give the digits of the required number: for 100 : 2 the remainders are 0, 0, 1, 0, 0, 1 and the last quotient is 1; read from bottom to top, 1100100. If a remainder is above 9, a letter is written (10 = A, 11 = B, …). When moving between two other systems, the decimal system is a “bridge”: first to decimal, then to the required base. Between systems with bases 2, 4, 8, 16 there is a shortcut: one octal digit matches a group of 3 binary digits (triad), one hexadecimal digit matches a group of 4 (tetrad), and one base-4 digit matches a group of 2 (dyad). For example 3C₁₆ = 0011 1100₂.

Worked examples
Convert 250 into base 7: 250 : 7 = 35 (remainder 5); 35 : 7 = 5 (remainder 0); the last quotient is 5. From bottom to top: 5, 0, 5 → 505₇. Check: 5 · 49 + 0 · 7 + 5 = 250.
Convert 753₈ to binary with triads: 7 = 111, 5 = 101, 3 = 011 → 111 101 011, i.e. 111101011₂. The reverse: group a binary number in threes from the right and replace each group by an octal digit.
Class activity

“Chain of remainders”: each team gets a decimal number. Pupils take turns at the board doing one division and writing the remainder; at the end the remainders are read from bottom to top. Teams with the right answer score points.

Practice
1
Convert 111010₂ to decimal.
2
Convert 78 to binary.
3
Convert 745₈ to binary using the triad table.
4
Why are the remainders read from bottom to top?