SLIDE 1
Lecture 18, IEEE Floating Point
CSCI341
SLIDE 2 Image courtesy of http://debsbookbag.blogspot.com/
SLIDE 3 The design team for a relationship-problem-solving-unit (RPSU) is choosing between a Candy and Flower
- implementation. Thousands of relationships may be at stake if
the problems aren’t solved efficiently.
SLIDE 4
Parameter Candy Flowers Clock Rate 500 MHz 35 MHz CPI for ALU 1 1 CPI for Control 2 1 CPI for Memory 2.7 1
For a program with 20% ALU instructions, 10% control instructions and 70% memory instructions, which design will be faster?
SLIDE 5 REVIEW
- We need to represent real numbers (very large, very small)
in a machine
- The agreed-upon standard is the IEEE Floating Point standard
SLIDE 6 IEEE FLOATING POINT STANDARD
- Single Precision (4 bytes / 32-bit encoding)
- Double Precision (8 bytes / 64-bit encoding)
SLIDE 7
SINGLE-PRECISION FLOATING POINT ENCODING
s= 1-bit sign e = 8-bit exponent f=23-bit significand
The MSB, 1, is implied. Think 24-bits. Biased exponent (because this isn’t your parents 2‘s complement system, this is IEEE rock and roll.) For single-precision FP , the bias is 127.
SLIDE 8 SINGLE-PRECISION FLOATING POINT ENCODING
s= 1-bit sign e = 8-bit exponent f=23-bit significand
(-1)s x 1.f x 10e-127 Think of this as “one zero” not ten
e-127 -> e - 01111111
SLIDE 9
BINARY TO DECIMAL
101.1012 111.0012 10.1012
SLIDE 10
DECIMAL TO BINARY
25.2510 12.210
SLIDE 11 ENCODE AS FLOATING POINT
- Place a value for the sign bit in the s field
- Normalize the binary number
- Add 127 (01111111) to the actual exponent
- place this in the e field
- Place the digits to the right of the binary point into the f field
s= 1-bit sign e = 8-bit exponent f=23-bit significand
SLIDE 12
ENCODE AS FLOATING POINT
s= 1-bit sign e = 8-bit exponent f=23-bit significand
12.2510 1001001.1010 0.101011 1.101010
SLIDE 13 DECODE FROM FLOATING POINT
s= 1-bit sign e = 8-bit exponent f=23-bit significand
- First bit is the sign bit, it remains the MSB
- Subtract 127 from e to find the actual exponent
- Extract the f bits into a normalized form: 1.f
- Denormalize the number
SLIDE 14
DECODE FROM FLOATING POINT
s= 1-bit sign e = 8-bit exponent f=23-bit significand 1 10000111 001100....0 10001000 101000....0 1 10001001 01100....0
SLIDE 15
PRECISION / RESOLUTION
What’s the big deal?
SLIDE 16 CONSIDER A SMALLER FORMAT...
sign exp sign 1 bit 3 bits 4 bits 1 101 1011
What is this in decimal?
(Biased by 3)
SLIDE 17
CONSIDER A SMALLER FORMAT...
sign exp sign 1 bit 3 bits 4 bits
How would you represent -6.76?
SLIDE 18 OK... SO WHAT ABOUT MIPS?
.data Pi: .double 3.1415926536897924 Rad: .double 12.345678901234567 .text main: l.d $f0, Pi # $f0 = Pi l.d $f4, Rad # $f4 = Rad mul.d $f12, $f4, $f4 # $f12 = Radius squared mul.d $f12, $f12, $f0 # Multiply by Pi li $v0, 3 syscall # Print the area li $v0, 10 syscall # Terminate the program
SLIDE 19
- Reading 16 (online)
- Chapter 11 of MIPS Assembly Language (pdf)
HOMEWORK
give me more!