Practice — Arithmetic for Computers

Work each one on paper first, then reveal. The ★ problems match the slides that are on your exam (19, 26–27, 57–66).

Signed numbers & overflow

A1A = 1011 is a 4-bit signed number in 2's complement form. What is its value?
A2B = 110101 is a 6-bit signed number. Give its decimal value, then sign-extend it to 10 bits.
A3Find the 2's complement (i.e. the negation) of the 8-bit number 0110 1100.
A44-bit numbers A = 0110 and B = 0011. Compute A − B using 2's complement addition.
A5big★ State when overflow occurs, and check whether these 4-bit operations overflow: (a) 0110 + 0011   (b) 1001 − 0111   (c) 0101 − 0011

Multiplication ★

B1big★ State the three steps of the multiplication algorithm and give its time and space complexity.
B2big★ Describe the hardware for the multiplication algorithm: name the registers and their widths for 32-bit operands.
B3bigMultiply 0011 × 0101 (3 × 5) using the algorithm. Show the register trace.
B4How does the algorithm handle signed multiplication?
B5Write MIPS code to compute $t0 = $t2 × $t1, and explain why two instructions are needed.

Division

C1State the division algorithm and explain why it is called “restoring”.
C2Give the quotient and remainder for all four sign combinations of 7 ÷ 2.
C3After a MIPS div instruction, where are the quotient and remainder? Write the code for j = i % 2 with i in $s0 and j in $s1.

Floating point ★

D1★ Draw the IEEE 754 single and double precision formats and write the value formula.
D2big★ Represent −0.75 in IEEE 754 single precision.
D3big★ Represent −10.75 in IEEE 754 single AND double precision.
D4big★ What decimal value is stored as 0 10000001 01000000000000000000000 (IEEE 754 single)?
D5Represent 6.25 in IEEE 754 single precision.
D6Convert 0.3125 to binary, and hence write 11.3125 in binary.
D7Explain overflow and underflow in floating point, and give an example of each.
D8What are ±∞ and NaN, and how are they encoded in single precision?