Binary math
Question 1:
Counting practice: count from zero to thirtyone in binary, octal, and hexadecimal:
Reveal Answer
No answers given here  compare with your classmates!
Notes:
In order to familiarize students with these ßtrange" 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.
Hide Answer
Question 2:
Add the following binary numbers:
Reveal Answer
Notes:
Ask your students to describe what differences exist between manually adding binary numbers and manually adding decimal numbers, if any.
Hide Answer
Question 3:
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.
Reveal Answer
No. The form of numeration used to represent numbers has no bearing on the outcome of mathematical operations.
Notes:
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 p 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:
 Me: How do you use a hand calculator to determine the circumference of a circle, given its diameter? For example, a circle with a diameter of 5 feet has a circumference of . . .
Him: By multiplying the diameter times "pi". 5 feet times "pi" is a little over 15 feet.
Me: Does a calculator give you the correct answer?
Him: Of course it does.
Me: Does an electronic calculator use decimal numbers, internally, to do math?
Him: No, it uses binary numbers, because its circuitry is made up of logic gates . . . (long pause) . . . Oh, now I see! If the type of number system mattered in doing math, digital computers and calculators would arrive at different answers for arithmetic problems than we would doing the math by hand!
Of course, those familiar with computer programming and numerical analysis understand that digital computers can introduce ärtifacts" 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.
Hide Answer
Question 4:
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:

·

10001010_{2}

·
 11010111_{2}

·
 11110011_{2}

·
 11111111_{2}

·
 11111_{2}

·
 00000000_{2}

·
 00000_{2}
Reveal Answer

·

10001010_{2}: One's complement = 01110101_{2}

·
 11010111_{2}: One's complement = 00101000_{2}

·
 11110011_{2}: One's complement = 00001100_{2}

·
 11111111_{2}: One's complement = 00000000_{2}

·
 11111_{2}: One's complement = 00000_{2}

·
 00000000_{2}: One's complement = 11111111_{2}

·
 00000_{2}: One's complement = 11111_{2}
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.
Notes:
The principle of a öne'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!
Hide Answer
Question 5:
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.
Reveal Answer
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.
Notes:
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!
Hide Answer
Question 6:
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:

·

01000101_{2} =

·
 01110000_{2} =

·
 11000001_{2} =

·
 10010111_{2} =

·
 01010101_{2} =

·
 10101010_{2} =

·
 01100101_{2} =
Reveal Answer

·

01000101_{2} = 69_{10}

·
 01110000_{2} = 112_{10}

·
 11000001_{2} = 63_{10}

·
 10010111_{2} = 105_{10}

·
 01010101_{2} = 85_{10}

·
 10101010_{2} = 86_{10}

·
 01100101_{2} = 101_{10}
Notes:
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.
Hide Answer
Question 7:
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.
Reveal Answer
Largest (most positive): 01111111
_{2} = 127
_{10}
Smallest (most negative): 10000000
_{2} =
128
_{10}
Notes:
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.
Hide Answer
Question 8:
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:
Reveal Answer
Notes:
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.
Hide Answer
Question 9:
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:
Reveal Answer
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.
Notes:
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!
Hide Answer
Question 10:
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?
Reveal Answer
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?
Notes:
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.
Hide Answer
Question 11:
What is a
floatingpoint number in a digital system?
Reveal Answer
"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 ßtandards" for representing floatingpoint numbers.
Notes:
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?
Hide Answer