Computer Arithmetic
Arithmetic and logic unit
-Does the calculations
-Everything else in the computer is there to service this unit
-Handles integers
-May handle floating point (real) numbers
-May be separate FPU (maths co-processor)
-May be on chip separate FPU (486DX +)
Integer Representation
-Only have 0 & 1 to represent everything
-Positive numbers stored in binary
-e.g. 41=00101001
-No minus sign
-No period
-sign-Magnitude
-Two’s compliment
Sign Magnitude
Left most bit is sign bit
-0 means positive
-1 means negative
+18 = 00010010
-18 = 10010010
Problems
-Need to consider both sign and magnitude in arithmetic
-Two representations of zero (+0 and -0)
Conversion Between Length
-Positive number pack with leading zeros
-+18 = 00010010
+18 = 00000000 00010010
Negative numbers pack with leading ones
-18 = 10010010
-18 = 11111111 10010010
-i.e. pack with MSB (sign bit)
Normalization
-FP numbers are usually normalized
i.e. exponent is adjusted so that leading bit (MSB) of mantissa is 1
-Since it is always 1 there is no need to store it
-(c.f. Scientific notation where numbers are normalized to give a single digit before the decimal point
e.g. 3.123 x 103)
No comments:
Post a Comment