Counting practice: count from zero to thirtyone in binary, octal, and hexadecimal:

No answers given here  compare with your classmates!
In order to familiarize students with these “strange” numeration systems, I like to begin each day of digital circuit instruction with counting practice. Students need to be fluent in these numeration systems by the time they are finished studying digital circuits!
One suggestion I give to students to help them see patterns in the count sequences is “pad” the numbers with leading zeroes so that all numbers have the same number of characters. For example, instead of writing “10” for the binary number two, write “00010”. This way, the patterns of character cycling (especially binary, where each successively highervalued bit has half the frequency of the one before it) become more evident to see.
Add the following binary numbers:


Ask your students to describe what differences exist between manually adding binary numbers and manually adding decimal numbers, if any.
If the numbers sixteen and nine are added in binary form, will the answer be any different than if the same quantities are added in decimal form? Explain.
No. The form of numeration used to represent numbers has no bearing on the outcome of mathematical operations.
Although this may seem like a trivial question, I’ve met electronics technicians who actually believed that the form of numeration affected the outcome of certain mathematical operations. In particular, I met one fellow who believed the number π was fundamentally different in binary form than it was in decimal form: that a binary “pi” was not the same quantity as a decimal “pi”. I challenged his belief by applying some Socratic irony:
Of course, those familiar with computer programming and numerical analysis understand that digital computers can introduce “artifacts” into computed results that are not mathematically correct. However, this is not due to their use of binary numeration so much as it is limited wordwidths (leading to overflow conditions), algorithmic problems converting floatingpoint to integer and visaversa, and such.
What is the one’s complement of a binary number? If you had to describe this principle to someone who just learned what binary numbers are, what would you say?
Determine the one’s complement for the following binary numbers:
Followup question: is the one’s complement 11111111_{2} identical to the one’s complement of 11111_{2}? How about the one’s complements of 00000000_{2} and 00000_{2}? Explain.
The principle of a “one’s complement” is very, very simple. Don’t give your students any hints at all concerning the technique for finding a one’s complement. Rather, let them research it and present it to you on their own!
Be sure to discuss the followup question, concerning the one’s complement of differentwidth binary numbers. There is a very important lesson to be learned here!
Determine the two’s complement of the binary number 01100101_{2}. Explain how you did the conversion, step by step.
Next, determine the two’s complement representation of the quantity five for a digital system where all numbers are represented by four bits, and also for a digital system where all numbers are represented by eight bits (one byte). Identify the difference that “word length” (the number of bits allocated to represent quantities in a particular digital system) makes in determining the two’s complement of any number.
The two’s complement of 01100101 is 10011011.
The two’s complement of five is 1011 in the fourbit system. It is 11111011 in the eightbit system.
The point about wordlength is extremely important. One cannot arrive at a definite two’s complement for any number unless the word length is first known!
In a computer system that represents all integer quantities using two’s complement form, the most significant bit has a negative placeweight. For an eightbit system, the place weights are as follows:

Given this placeweighting, convert the following eightbit two’s complement binary numbers into decimal form:
Students accustomed to checking their conversions with calculators may find difficulty with these examples, given the negative place weight! Two’s complement notation may seem unusual at first, but it possesses decided advantages in binary arithmetic.
In an eightbit digital system, where all numbers are represented in two’s complement form, what is the largest (most positive) quantity that may be represented with those eight bits? What is the smallest (most negative) quantity that may be represented? Express your answers in both binary (two’s complement) and decimal form.
Largest (most positive): 01111111_{2} = 127_{10}
Smallest (most negative): 10000000_{2} = −128_{10}
The most important concept in this question is that of range: what are the limits of the representable quantities, given a certain number of bits. Two’s complement just makes the concept a bit more interesting.
Two’s complement notation really shows its value in binary addition, where positive and negative quantities may be handled with equal ease. Add the following bytelong (8 bit) two’s complement numbers together, and then convert all binary quantities into decimal form to verify the accuracy of the addition:


Have your students do some of these problems on the board, in front of class for all to see. Ask students what happens to the leftmost “carry” bit, if it exists in any of these problems. Ask them why we do what we do with that bit, when we would usually place it in our answer.
Add the following eightbit two’s complement numbers together, and then convert all binary quantities into decimal form to verify the accuracy of the addition:


Followup question: Why are some of these answers incorrect? Hint: perform the additions in decimal form rather than binary form, and then explain why those answers are not represented in the binary answers.
This question introduces students to the phenomenon of overflow. This is a very important principle to understand, because real computer systems must deal with this condition properly, so as not to output incorrect answers!
How is it possible to tell that overflow has occurred in the addition of binary numbers, without converting the binary sums to decimal form and having a human being verify the answers?
Check the sign bit of the answer, and compare it to the sign bits of the addend and augend.
Challenge question: under what condition(s) is overflow impossible? When can we add two binary numbers together and know with certainty that the answer will be correct?
Later, this concept of overflow checking should be applied to a real circuit, with students designing logic gate arrays to detect the presence of overflow. First, though, they must learn to recognize its presence analytically.
What is a floatingpoint number in a digital system?
“Floatingpoint” numbers are the binary equivalent of scientific notation: certain bits are used to represent the mantissa, another collection of bits represents the exponent, and (usually) there is a single bit representing sign. Unfortunately, there are several different “standards” for representing floatingpoint numbers.
Ask your students why computer systems would have need for floating point numbers. What’s wrong with the standard forms of binary numbers that we’ve explored thus far?
Published under the terms and conditions of the Creative Commons Attribution License
by Cabe Atwell
by Robert Keim
by Gary Elinoff
by Robert Keim