Computer Arithmetic
Arithmetic & Logic Unit zDoes the calculations zEverything else in the computer is there to service this unit zHandles integers zMay handle floating point (real) numbers zMay be separate FP (maths co-processor)
ALU Inputs and Outputs
Integer Representation zOnly have 0 & 1 to represent everything zPositive numbers stored in binary ye.g. 41= zNo minus sign zNo period zSign-Magnitude zTwo’s compliment
Sign-Magnitude zLeft most bit is sign bit z0 means positive z1 means negative z+18 = z -18 = zProblems yNeed to consider both sign and magnitude in arithmetic yTwo representations of zero (+0 and -0)
Addition and Subtraction zNormal binary addition zMonitor sign bit for overflow zTake twos compliment of substahend and add to minuend yi.e. a - b = a + (-b) zSo we only need addition and complement circuits
Hardware for Addition and Subtraction
Multiplication zComplex zWork out partial product for each digit zTake care with place value (column) zAdd partial products
Division zMore complex than multiplication zNegative numbers are really bad! zBased on long division