Docsity

Floating Point Operations: Addition and Multiplication, Assignments of Computer science

Partial preview of the text

Download Floating Point Operations: Addition and Multiplication and more Assignments Computer science in PDF only on Docsity!

Floating Point Operation

Floating Point

  • (^) +/- .significand x 2 exponent
  • (^) Misnomer
  • (^) Point is actually fixed between sign bit and body of mantissa
  • (^) Exponent indicates place value (point position) Misnomer:เเเเเเเเเเเเ, เเเ

Signs for Floating Point

• Mantissa is stored in 2s compliment

• Exponent is in excess or biased notation

  • (^) e.g. Excess (bias) 128 means
  • (^) 8 bit exponent field
  • (^) Pure value range 0-
  • (^) Subtract 128 to get correct value
  • (^) Range -128 to +

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 10

3

Expressible Numbers

IEEE 754 Formats

FP Arithmetic +/-

• Check for zeros

• Align significands (adjusting exponents)

• Add or subtract significands

• Normalize result

Floating-Point Addition

  • (^) Consider a 4-digit decimal example
    • (^) 9.999 × 10 1 + 1.610 × 10 -
  • (^) 1. Align decimal points
    • (^) Shift number with smaller exponent
    • (^) 9.999 × 10 1 + 0.016 × 10 1
  • (^) 2. Add significands
    • (^) 9.999 × 10 1 + 0.016 × 10 1 = 10.015 × 10 1
  • (^) 3. Normalize result & check for over/underflow
    • (^) 1.0015 × 10 2
  • (^) 4. Round and renormalize if necessary
    • (^) 1.002 × 10 2 Lec 14 Systems Architecture 13

Floating-Point Addition

  • (^) Now consider a 4-digit binary example  (^) 1. 2

× 2

    • –1. 2

× 2

  • (0.5 + –0.4375)
  • (^) 1. Align binary points  (^) Shift number with smaller exponent  (^) 1. 2

× 2

    • –0. 2

× 2

  • (^) 2. Add significands  (^) 1. 2

× 2

    • –0. 2

× 2

  • 1 = 0. 2

× 2

  • (^) 3. Normalize result & check for over/underflow  (^) 1. 2

× 2

  • , with no over/underflow
  • (^) 4. Round and renormalize if necessary  (^) 1. 2

× 2

  • (no change) = 0. Lec 14 Systems Architecture 14

16 Floating Point Multiplication Algorithm