Computer Architecture Lecture 11 Arithmetic Ralph Grishman Oct NYU
Overflow (for two’s complement arithmetic) value too large to represent in (32-bit) word for addition, occurs when you add two positive numbers and get a negative result you add two negative numbers and get a positive result 10/13/15Computer Architecture lecture 112
Multiplication sequential circuit 10/13/15Computer Architecture lecture 113
Multiplication sequential circuit, shared register 10/13/15Computer Architecture lecture 114
Multiplication combinatorial circuit n rows of adders, one for each multiplier bit 10/13/15Computer Architecture lecture 115
Multiplication tree of adders 10/13/15Computer Architecture lecture 116
Multiplication carry save: carries propagated diagonally (see diagram with lecture notes) 10/13/15Computer Architecture lecture 117
Division Sequential circuit 10/13/15Computer Architecture lecture 118
Division Harder to speed up but programs don’t divide very often 10/13/15Computer Architecture lecture 119
Floating point representation: sign S, exponent E, and fraction F value = (-1) S × F × 2 E IEEE 754 floating-point standard standard sizes standard representations for 0, ∞, … makes floating code portable 10/13/15Computer Architecture lecture 1110 sizesize of E fieldsize of F field single precision32 bits8 bits23 bits double precision64 bits11 bits52 bits
Floating point addition Basic algorithm: 1.align decimal points 1.if exponents differ, adjust operand with smaller exponent so exponents are equal 2.add fractions 3.normalize result 10/13/15Computer Architecture lecture 1111
Floating point addition Example (decimal): 0.95 x x /13/15Computer Architecture lecture 1112
Floating point addition Example (decimal): 0.95 x x /13/15Computer Architecture lecture 1113
Floating point addition Example (decimal): 0.95 x x x /13/15Computer Architecture lecture 1114
Floating point addition Example (decimal): 0.95 x x x /13/15Computer Architecture lecture 1115
Floating point multiplication Basic algorithm: add exponents, multiply fractions 10/13/15Computer Architecture lecture 1116
Precision Why do we need such precision (particularly, double precision)? What do we measure so precisely? 10/13/15Computer Architecture lecture 1117