A motivated high school student can usually obtain appropriate high school math preparation for an electrical and computer engineering (ECE) or computer science course of study. Algebra, geometry, trigonometry, and calculus are widely available in many high schools, and these are mostly sufficient for a freshman engineering student.
However, some topics needed for ECE are often covered briefly at best in the secondary math curriculum. One such topic is generalized number bases, including binary, hexadecimal, and octal numbers. A surprising number of freshman ECE students, even at highly respected universities, have no idea how to convert among numbers expressed in the following bases:
Overview of binary numbers
Binary numbers are the basis of modern computers, which use 0 and 1 to represent OFF and ON states in digital circuits. Just as the decimal number system uses the ten digits 0 through 9, the binary number system uses the two digits 0 and 1. For example, a binary number might be written as shown below.
Figure 1: A binary number
In addition, just as the place values of the base ten system are 100, 101, 102, 103, 104, and so on, the place values of base 2 begin with 20, 21, 22, 23, 24, as shown below.
Figure 2: A binary number with base ten place values
Therefore, the value of the binary number above is the sum of the place values with 1’s in them:
Value of binary number = 32,768+16,384+4,096+1,024+512+256+8+2 = 55,050
Overview of octal and hexadecimal numbers
One challenging aspect of binary numbers is that they are long and difficult to read. While it is easy to read “fifty-five thousand, fifty”, the number “one, one, zero, one, zero, one, one, one, zero, zero, zero, zero, one, zero, one, zero” is a bit awkward (apologies for the pun).
To reduce the awkwardness of binary numbers, we often group binary digits into groups of three or four digits from right to left. Groups of three bits are represented as 0 to 7 (octal), and groups of four bits are represented as 0 to F (hexadecimal), as shown below.
The place values of octal numbers are 80, 81, 82, 83, and so on. We can therefore convert a binary number to octal three bits at a time and evaluate it as shown below:
Figure 3: Converting a binary number to octal, three bits at a time
Adding the numbers shown in the Product row, we see that the octal number 153412 is equivalent to the base 10 number 55,050.
A hexadecimal example
Finally, we can group the bits four at a time to convert them to base 16 (hexadecimal), as shown below.
Figure 4: Converting a binary number to hexadecimal, four bits at a time
Practice converting between bases
To practice these conversions, consider using Excel to generate test cases. Excel has 12 functions, named DEC2BIN, HEX2OCT, OCT2DEC, and so on that convert among the various number bases. You simply specify the input number and, in some cases, the number of digits you want in the output. For example, =DEC2BIN(185,10) converts the decimal number 185 into the 10-digit binary number 0010111001.
University ECE departments expect incoming students to understand number bases, but many students never receive appropriate instruction on this in high school. Students who are unfamiliar with these concepts should spend some time studying them before they arrive on campus to start studying ECE or computer science.