Floating Point Number Representation and Arithmetic CS 3432
Floating Point Number Representation and Arithmetic CS 3432 Fall 2020 Shirley Moore, Instructor svmoore@utep. edu December 1, 2020 1
Schedule for Today’s Class • Announcements • • • Quiz 5 extended to 3 attempts, due date extended to 11: 59 pm Wed. , Dec. 2 Please do course evaluations! (separate evaluations for lecture and lab) Lab 5 “due” Monday, Dec. 7; schedule demo this week or next Midterm Exam grades have been adjusted with retake results. Final Exam in parts, hope to have it available Dec. 4, due Dec. 11 • Review of data and control hazards and data forwarding (15 min) • P&H Exercises 4. 29. 1 -4. 29. 3 (10 minutes) • Homework from last class (10 minutes) • Floating point (40 minutes) • Wrapup • Homework for next class: Floating Point Practice Problems 2
Homework from Last Class • Demo: C program that emulates multiplication using shifts and addition • What is the time complexity of the algorithm? The loop executes at most once for each bit of the multiplier, so the worst-case time complexity is logarithmic in the size of the multiplier. • Write a program in C or RISC-V assembly that emulates division using add, sub, and/or shifts (Extra credit for Lab 5) • Experiment in Venus to answer the following questions about RISC-V division: Let’s try it! • What results are produced for the quotient and remainder when division by zero occurs? • What is the one case for division that can result in overflow and what are the quotient and remainder results for this case? 3
RISC-V Floating Point • Chapter 3 Slides 16 -39 4
Floating Point Learning Outcomes for Final Exam • For the Final Exam, you should be able to • Tell which bits are used for the sign, exponent, and mantissa in IEEE 754 standard single and double precision representations. • Given the hexadecimal encoding for a 32 -bit or 64 -bit floating point number, write the number in binary or decimal scientific notation. • Given a number in binary or decimal scientific notation, write the hexadecimal 32 -bit (64 -bit) hexadecimal floating point representation. • Normalize a floating point number • Describe and use the hardware algorithm for adding two floating point numbers. • Describe and use the hardware algorithm for multiplying two floating point numbers. • Determine whether a number can be represented in 32 -bit (64 -bit) floating point representation, possibly with roundoff error. • Determine whether a number can be represented exactly in 32 -bit (64 -bit) floating point representation – i. e. , with no roundoff error. • Write a simple computation using RISC-V floating point instructions. 5
- Slides: 5