In: Computer Science
One day Tom found a weird-looking computer in his basement. After studying it, Tom figured out that this computer stores floating point numbers in a way similar to the IEEE 754 standard. However, it uses 26 bits. Among these bits, the most significant (i.e. the leftmost) bit is for the sign (same as IEEE 754), the following 6 bits are for the biased exponent with the bias as 31, and the rest are for the significand. If the real number -0.84375 is stored on the computer, what are the 26 bits stored? Show the result in the order of sign, biased exponent and significand. Separate them by comma.
Answer: -------- 1,011110,1011000000000000000 Explanation: ------------- Converting 0.84375 to binary Convert decimal part first, then the fractional part > First convert 0 to binary Divide 0 successively by 2 until the quotient is 0 Read remainders from the bottom to top as So, 0 of decimal is in binary > Now, Convert 0.84375000 to binary > Multiply 0.84375000 with 2. Since 1.68750000 is >= 1. then add 1 to result > Multiply 0.68750000 with 2. Since 1.37500000 is >= 1. then add 1 to result > Multiply 0.37500000 with 2. Since 0.75000000 is < 1. then add 0 to result > Multiply 0.75000000 with 2. Since 1.50000000 is >= 1. then add 1 to result > Multiply 0.50000000 with 2. Since 1.00000000 is >= 1. then add 1 to result > This is equal to 1, so, stop calculating 0.84375 of decimal is .11011 in binary so, 0.84375 in binary is .11011 -0.84375 in simple binary => .11011 so, -0.84375 in normal binary is .11011 => 1.1011 * 2^-1 26-bit format: -------------------- sign bit is 1(-ve) exp bits are (31-1=30) => 011110 Divide 30 successively by 2 until the quotient is 0 > 30/2 = 15, remainder is 0 > 15/2 = 7, remainder is 1 > 7/2 = 3, remainder is 1 > 3/2 = 1, remainder is 1 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 11110 So, 30 of decimal is 11110 in binary frac bits are 1011000000000000000 so, -0.84375 in 26-bit format is 1 011110 1011000000000000000