Computer ArithmeticThe ALUSign-MagnitudeTwos ComplementConverting Bit LengthInteger Math NegationInteger Math AdditionInteger Math SubtractionInteger Math MultiplicationInteger Math DivisionFloating PointFloating Point Math Addition & SubtractionFloating Point Math Multiplication & DivisionGrant HardinArithmetic Logic UnitThe Component that performs arithmetic and logic operationsEverything else exists to bring data to the ALUBased on simple Boolean logic operations.Alternate representation of numberLeftmost bit is sign while the rightmost n-1 bits are magnitudeHas several drawbacks and is rarely used+18 = 00010010-18 = 10010010+0 = 00000000-0 = 10000000Most common representation of numbersMSB is sign indicatorAll bits are interpretedFor positive values, just add 0s +18 = 00010010 +18 = 0000000000010010For negatives•Move sign bit to leftmost position•Fill with copies of sign bit -18 = 11101110 -18 = 1111111111101110Formally:1.Take the Boolean complement of each bit2.Add 1 +18 = 00010010bitwise complement = 11101101 + 1 ------------ 11101110 = -18Take both values as unsigned intsOverflow Rule•If both numbers are positive or negative, overflow occurs if the result is the opposite sign.Take the twos complement of the subtrahendAdd this to the minuendOverflow still appliesSimilar to paper-pen multiplicationGenerate partial products and sum themRemember to pad negative twos complement numbersAgain, similar to paper-pencilGenerate partial divisors and subtractRemember to subtract as unsigned integerUses a fixed binary point to allow fractionsLimited•Cannot represent very large numbers•Or very small Fractions1. Check for zeros2. Align significands3. Add or subtract significands4. Normalize
View Full Document