L12-ac-fp2-mips-machine3-6up

L12-ac-fp2-mips-machine3-6up -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS61C L12 Floating Point I , MIPS Instruction Format I I (1) Chae, Summer 2008 © UCB Albert Chae, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #12 – Floating Point II, MIPS Instruction Format III 2008-7-10 CS61C L12 Floating Point I , MIPS Instruction Format I I (2) Chae, Summer 2008 © UCB Review Floating Point numbers approximate values that we want to use. Summary (single precision): 0 31 S Exponent 30 23 22 Significand 1 bit 8 bits 23 bits (-1) S x (1 + Significand) x 2 (Exponent-127) Why do we use bias? Double precision same idea with more bits - 11 bit exponent, bias of 1023 - 52 bit significand CS61C L12 Floating Point I , MIPS Instruction Format I I (3) Chae, Summer 2008 © UCB Peer Instruction from yesterday There is no interval of numbers where the gap between a floating point representation and the next biggest is 1. False ? ???? ???? 000 0000 0000 0000 0000 0001 ? ???? ???? 000 0000 0000 0000 0000 0000 CS61C L12 Floating Point I , MIPS Instruction Format I I (4) Chae, Summer 2008 © UCB Converting Decimal to FP (1/4) Simple Case: If denominator is an exponent of 2 (2, 4, 8, 16, etc.), then it’s easy. Show MIPS representation of -0.75 -0.75 = -3/4 -11 two /100 two = -0.11 two Normalized to -1.1 two x 2 -1 (-1) S x (1 + Significand) x 2 (Exponent-127) (-1) 1 x (1 + .100 0000 . .. 0000) x 2 (126-127) 1 0111 1110 100 0000 0000 0000 0000 0000 CS61C L12 Floating Point I , MIPS Instruction Format I I (5) Chae, Summer 2008 © UCB Converting Decimal to FP (2/4) Not So Simple Case: If denominator is not an exponent of 2. Then we can’t represent number precisely, but that’s why we have so many bits in significand: for precision Once we have significand, normalizing a number to get the exponent is easy. So how do we get the significand of a neverending number? CS61C L12 Floating Point I , MIPS Instruction Format I I (6) Chae, Summer 2008 © UCB Converting Decimal to FP (3/4) Fact: All rational numbers have a repeating pattern when written out in decimal. Fact: This still applies in binary. To finish conversion: Write out binary number with repeating pattern. Cut it off after correct number of bits (different for single v. double precision). Derive Sign, Exponent and Significand fields.
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS61C L12 Floating Point I , MIPS Instruction Format I I (7) Chae, Summer 2008 © UCB Example: Representing 1/3 in MIPS 1/3 = 0.33333… 10 = 0.25 + 0.0625 + 0.015625 + 0.00390625 + … = 1/4 + 1/16 + 1/64 + 1/256 + = 2 -2 + 2 -4 + 2 -6 + 2 -8 + … = 0.0101010101… 2 * 2 0 = 1.0101010101… 2 * 2 -2 Sign: 0 Exponent = -2 + 127 = 125 = 01111101 Significand = 0101010101… 0 0111 1101 0101 0101 0101 0101 0101 010 CS61C L12 Floating Point I , MIPS Instruction Format I I (8) Chae, Summer 2008 © UCB Converting Decimal to FP (4/4) 1. Denormalize: -23.40625 2. Convert integer part: 23 = 16 + ( 7 = 4 + ( 3 = 2 + ( 1 ) ) ) = 10111 2 3. Convert fractional part:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

L12-ac-fp2-mips-machine3-6up -...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online