17 - Floating Point 1 Topics IEEE754Standard RoundingMode...

This preview shows pages 1–12. Sign up to view the full content.

1 Floating Point

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Topics Fractional Binary Numbers IEEE 754 Standard Rounding Mode FP Operations Floating Point in C Suggested Reading: 2.4
3 Encoding Rational Numbers Form V = Very useful when        >> 0 or       <<1 An Approximation to real arithmetic From programmer’s perspective Uninteresting Arcane and incomprehensive y x 2 × V V

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Fractional Binary Numbers b m b m –1 b 2 b 1 b 0 b –1 b –2 b –3 b n • • • • • • . 1 2 4 2 m –1 2 m • • • • • • 1/2 1/4 1/8 2 n
5 Fractional Binary Numbers Bits to right of “binary point” represent fractional powers of 2 Represents rational number:        2 i - = m n i i b

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Fractional Numbers to Binary Bits unsigned result_bits=0, current_bit=0x80000000 for (i=0;i<32;i++) { x *= 2 if ( x>= 1 ) { result_bits |= current_bit ; if ( x == 1) break ; x -= 1 ; } current_bit >> 1 ; }
7 Fraction Binary Number Examples Value Binary Fraction 0.2 0.00110011[0011] Observations: The form 0.11111…11 represent numbers just below 1.0 which is  noted as 1.0- ε Binary Fractions can only exactly represent x/2 k Others have repeated bit patterns

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 Encoding Rational Numbers Until 1980s Many idiosyncratic formats, fast speed, easy  implementation, less accuracy IEEE 754 Designed by W. Kahan for Intel processors (Turing  Award 1989) Based on a small and consistent set of principles,  elegant, understandable, hard to make go fast
9 IEEE Floating-Point Representation Numeric form V=(-1) s × ×  2 E Sign bit  s  determines whether number is negative or positive Significand  M    normally a fractional value in range [1.0,2.0). Exponent  E  weights value by power of two

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
10 IEEE Floating-Point Representation Encoding   s is sign bit exp  field encodes  E frac  field encodes  M Sizes Single precision (32 bits): 8 exp bits, 23 frac bits Double precision (64 bits): 11 exp bits, 52 frac bits s exp frac
11 Normalize Values Condition   exp     000 0  and  exp     111 1 Exponent coded as biased value E  =  Exp – Bias Exp : unsigned value denoted by  exp Bias : Bias value Single precision: 127 (Exp: 1…254, E : -126…127)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/19/2011 for the course CS 000 taught by Professor Jing during the Fall '10 term at Fudan University.

Page1 / 44

17 - Floating Point 1 Topics IEEE754Standard RoundingMode...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online