Docsity

Floating Point Representation: Binary Fractions and Scientific Notation, Study notes of Computer Science

Partial preview of the text

Download Floating Point Representation: Binary Fractions and Scientific Notation and more Study notes Computer Science in PDF only on Docsity!

Floating PointFloating Point

RepresentationRepresentation

September 13, 2000September 13, 2000

CSC201 Section 002

Fall, 2000

Floating Point Floating Point

  • The computer representation for real

numbers

  • Hardware support on most processors

(special instructions)

  • Advantages
    • much greater range
    • uniform precision

Binary Fractions (cont.) Binary Fractions (cont.)

  • Converting decimal fraction to binary

fraction

  • multiply the fractional part by two repeatedly
  • the integer portion at each step is the next binary digit, from msb to lsb
  • stop when the fraction = 0

Example: convert .3125_10 to binary

(Binary) Scientific Notation (Binary) Scientific Notation

  • A number is represented as

(-1) s^ * m * b e^ , where…

  • s = sign bit
  • m = mantissa
  • b = base
  • e=exponent
  • In the IEEE floating point standard...
  • b = 2 (implicit, not stored)
  • s = sign (1 bit)
  • m = signed magnitude binary representation (23 bits + implicit 24th)
  • e = biased-127 binary representation ( bits), allowable range is -126 <= e <= +

Precision, Significant Digits, and Precision, Significant Digits, and AccuracyAccuracy

  • Precision = accuracy of a

measurement

  • Leading zeros don’t count as digits of

precision

  • Trailing zeros may or may not be digits of precision
  • Goal for arithmetic: maintain

maximum precision at all times

  • Single and double precision

How many digits of (decimal) precision? 198

001980

Normalization Normalization

  • Mantissa is (almost) always stored so

that it is in the range 1.0 <= m < 2

  • reason: preserve maximum precision at all times!
  • Normalized: 1.110, 1.000, 1.111, 1.
  • Not normalized: 0.110, 11.10, 10.
  • "Normalizing" means shifting

mantissa to be in this form

  • for each shift right, add 1 to the exponent value
  • for each shift left, subtract 1 from the exponent value Ex.: normalize .00101_2 * 2 5 = 0.0101 * 2 4 = 0.101 * 2 3 = 1.01 * 2 2