Download presentation
Presentation is loading. Please wait.
Published byPenelope Merritt Modified over 9 years ago
1
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text
2
Review Last time we looked at binary representations of floating point numbers and the IEEE 754 standard. This time we will continue with the IEEE Standard 754
3
IEEE Standard 754-2008 Recall that the IEEE Standard 754 denotes the standard representation for floating point numbers. 32 bit floating point numbers are represented in binary scientific notation. Recall that decimal floating point numbers are represented in scientific notation as follows: +/- x.xxxxx * 10 ^ +/- y Appropriate representations of x.xxxxx are between -9.99999 and 9.99999. Notice that 10.5 * 10 ^ 7 is an improper representation. The appropriate representation is 1.05 * 10^8 where x is the significand and y is the exponent. In binary, we may represent scientific notation as: +/- x.xxxxxx * 2 ^ +/- y sign-bitexponentsignificand 1-bit8-bit23-bit
4
Examples The sign bit denotes whether the significand is positive or negative The exponent is a biased binary number and may represent a value between -127 and 126 Biased binary numbers are those in which we have a range of numbers and choose a value to represent zero. All values greater than that point are positive. All less than that point are negative. Take 4 bit numbers as an example. 0000 <-- -8d 0001 <-- -7d 0010 <-- -6d 0011 <-- -5d 0100 <-- -4d 0101 <-- -3d 0110 <-- -2d 0111 <-- -1d 1000 <-- 0d Notice that this representation is biased because we moved zero. 1001 <-- 1d 1010 <-- 2d 1011 <-- 3d 1100 <-- 4d 1101 <-- 5d 1110 <-- 6d 1111 <-- 7d <- This value is used for infinity
5
Biased Representation A bias is an movement to one side or an offset. We offset our representation of zero by half of our range. This is useful in representing the exponent because it makes comparison of floating point values easy. The significand represents an unsigned binary value less than 2 decimal. Notice that thisvalue will always be greater than or equal to one unless it is zero. Therefore, we will ignorethe leading one in the significand. Simply put, the significand denotes the significant bits of the value we are trying to represent.
6
Examples Let's examine a decimal value. Take 123.5 as an example. A binary representation of this value is as follows: 1111011.1b To convert this to IEEE Standard 754 representation, we move the decimal place to the left six places. Now the representation is as follows: 1.1110111b * 2d ^ 6d Using biased binary with 8 bits, our range starts at -127 (0x00) and goes to 126 (0xfe) 6d = 110b 6 + 127 = 133 So, our representation of 123.5 is 1.1110111b * 2d ^ 6d which is converted to 1.1110111b * 2d ^ 1000 0101b using biased binary. Our sign bit is 0 since we are using a positive number, so our representation is now: 01000 01011110 1110 0000 0000 0000 000 signexponentsignificand (23 bits) Notice that we dropped the leading one in the significand.
7
Examples Let's look at another example. Take 205.4 as an example. 205.4 is converted as follows: 205 % 2 = 1 102 % 2 = 0 51 % 2 = 1 25 % 2 = 1 12 % 2 = 0 6 % 2 = 0 3 % 2 = 1 1 Notice that 205d = 11001101 0.4 * 2 --------- 0.8 * 2 1.6 --> 0.6 * 2 1.2 --> 0.2 * 2 0.4 * 2 0.8 * 2 1.6 --> 0.6 * 2 1.2 --> 0.2 * 2 0.4 * 2 0.8 * 2 1.6 --> 0.6 * 2 1.2 --> 0.2 * 2 0.4 * 2…. So, our result is 11001101.011001100110011001100110011...
8
Representation Result is 11001101.011001100110011001100110011... We then move the decimal point to the left by seven places yielding: 1.1001101011001100110011001100110011... * 2 ^ 7 Now our IEEE 754 representation is: 01000 01101001 1010 1100 1100 1100 110 signexponentsignificand For the exponent, the result is 7+127 = 134 = 128 + 4 + 2
9
Zero and +/- Infinity In the IEEE 754-2008 standard zero is represented as follows: 00000 00000000 0000 0000 0000 0000 000 signexponentsignificand Positive Infinity is represented as: 01111 11110000 0000 0000 0000 0000 000 Negative Infinity is represented as: 11111 11110000 0000 0000 0000 0000 000 NAN – Not a Number 11111 1111xxxx xxxx xxxx xxxx xxxx xxx Where x’s are anything other than all zeroes.
10
More Examples Convert 204.5d to IEEE 754-2008 Format First, convert to binary - 11001100.1 b Then change the value to binary scientific format 1.10011001 * 2^7 subtract bias of -127 7 - -127 = 134 = 128 + 4 + 2 1000 0110
11
Example, Continued We assume the 1.0b is going to always be there so the result is: sign exponent significand 0 1000 0110 1001 1001 0000 0000 0000 000 0x434C8000
12
Working Backwards from MIPS Using MIPS find the hex value of -0.05432, (this is a float value) 0xBD5E7EA6 1011 1101 0101 1110 0111 1110 1010 0110 sign exponent significant 1 0111 1010 101 1110 0111 1110 1010 0110 26 + 96 = 122 -5 = 122 - 127 1.x * 2^-5
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.