Docsity

Floating Point Arithmetic: Notation, Representation, and IEEE 754 Standards in CS365, Study notes of Computer Architecture and Organization

Partial preview of the text

Download Floating Point Arithmetic: Notation, Representation, and IEEE 754 Standards in CS365 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

CS365 1

Floating Point Arithmetic

CS 365 Lecture 8 Prof. Yih Huang

CS365 2

Scientific Notation

6.02 x 10 23

exponent

Mantissa radix (base)

decimal point

Sign, magnitude

Sign, magnitude

CS365 3

Floating Point Numbers

 We need a way to represent

  • numbers with fractions, e.g., 3.
  • very small numbers, e.g.,.
  • very large numbers, e.g., 3.15576 × 109  Representation:
  • sign, exponent, significand:

(–1)sign^ ×××× significand ×××× 2 exponent

  • more bits for significand gives more accuracy
  • more bits for exponent increases range

CS365 4

Issues

 Arithmetic (+, -, ×, /)  Representation, Normal form  Range and Precision  Rounding  Exceptions (e.g., divide by zero, overflow, underflow)  Errors

CS365 7

Discussions

Leading “1” bit of significand is implicit

Exponent is “biased”

  • bias of 127
  • all 0s is smallest exponent; all 1s is

largest

 Magnitude of numbers that can be represented: 2-126^ to 2^127 (2− 2 -23)  Or in decimal numbers: 1.8×10-38^ to 3.4×10^38

CS365 8

Exercise

 Give the single precision representation of 1.0.

 Give the single precision representation of -0.

 Give the single precision representation of 0.

CS365 9

Exercise

 Calculate the value of

0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

CS365 10

Floating Point Arithmetic

 Step 1: alignment of decimal point

 Step 2: add significands

 Step 3: normalization