Lab03 BinaryArithmetic
Lab03 BinaryArithmetic
James T. Smith
San Francisco State University
The two binary digits 0 and 1 are called bits.1 Often we use a subscript to indicate the
base:
(We write the base and the exponents with decimal numerals.)
You can use equations like the previous one to convert from binary to decimal
numerals:
1
This term is due to John Tukey. Click here for his biographical sketch and portraits on the St. Andrews
website.
15 September 2003
Page 2 BINARY ARITHMETIC
binary decimal
101011 43
+1011 +11
S)))))Q S))Q
= 110110 = 54
You can subtract binary numerals as you subtract decimals, but borrowing is
perplexing:
binary decimal
01001
110110 54
–1011 –11
S)))))Q S))Q
= 101011 = 43
To multiply a binary numeral by 2 p you just shift it left p places, filling on the
right with zeros. Multiplication in general consists of shifting and adding:
BINARY ARITHMETIC Page 3
101011
×1011
S)))))Q
101011
101011
101011
S))))))))Q
111011001
You can also think of multiplying a binary numeral by 2 p as moving the binary
point rightward p places. Dividing by 2 p moves the point leftward p places. Long
division works as it does with decimal numerals:
.1
10 1.0 ( 1) 2 )10 = (.1) 2
.00110011
101 1.00000000 ( 1) 5 )10 = ( .0011 ) 2
101
110
101
1000
101
110
101
%
For some fractions, the decimal expansion terminates but the binary expansion does not.
Page 4 BINARY ARITHMETIC
Exercises
2. Convert the two addends in exercise 1 and their sum to decimal and use the
results to check your addition in exercise 1.
5. Convert the two factors in exercise 4 and their product to decimal and check your
multiplication in exercise 4.