Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text
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
IEEE Standard 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 and 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
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 <-- -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 <-- 1d 1010 <-- 2d 1011 <-- 3d 1100 <-- 4d 1101 <-- 5d 1110 <-- 6d 1111 <-- 7d <- This value is used for infinity
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.
Examples Let's examine a decimal value. Take as an example. A binary representation of this value is as follows: b To convert this to IEEE Standard 754 representation, we move the decimal place to the left six places. Now the representation is as follows: b * 2d ^ 6d Using biased binary with 8 bits, our range starts at -127 (0x00) and goes to 126 (0xfe) 6d = 110b = 133 So, our representation of is b * 2d ^ 6d which is converted to b * 2d ^ b using biased binary. Our sign bit is 0 since we are using a positive number, so our representation is now: signexponentsignificand (23 bits) Notice that we dropped the leading one in the significand.
Examples Let's look at another example. Take as an example is converted as follows: 205 % 2 = % 2 = 0 51 % 2 = 1 25 % 2 = 1 12 % 2 = 0 6 % 2 = 0 3 % 2 = 1 1 Notice that 205d = * * > 0.6 * > 0.2 * * * > 0.6 * > 0.2 * * * > 0.6 * > 0.2 * * 2…. So, our result is
Representation Result is We then move the decimal point to the left by seven places yielding: * 2 ^ 7 Now our IEEE 754 representation is: signexponentsignificand For the exponent, the result is = 134 =
Zero and +/- Infinity In the IEEE standard zero is represented as follows: signexponentsignificand Positive Infinity is represented as: Negative Infinity is represented as: NAN – Not a Number xxxx xxxx xxxx xxxx xxxx xxx Where x’s are anything other than all zeroes.
More Examples Convert 204.5d to IEEE Format First, convert to binary b Then change the value to binary scientific format * 2^7 subtract bias of = 134 =
Example, Continued We assume the 1.0b is going to always be there so the result is: sign exponent significand x434C8000
Working Backwards from MIPS Using MIPS find the hex value of , (this is a float value) 0xBD5E7EA sign exponent significant = = x * 2^-5