In: Computer Science
Binary conversion:
Convert 1234.5869 × 103 to IEEE 745 (show your work)
1234.5869 * 10^3 = 1234586.9 Converting 1234586.9 to binary Convert decimal part first, then the fractional part > First convert 1234586 to binary Divide 1234586 successively by 2 until the quotient is 0 > 1234586/2 = 617293, remainder is 0 > 617293/2 = 308646, remainder is 1 > 308646/2 = 154323, remainder is 0 > 154323/2 = 77161, remainder is 1 > 77161/2 = 38580, remainder is 1 > 38580/2 = 19290, remainder is 0 > 19290/2 = 9645, remainder is 0 > 9645/2 = 4822, remainder is 1 > 4822/2 = 2411, remainder is 0 > 2411/2 = 1205, remainder is 1 > 1205/2 = 602, remainder is 1 > 602/2 = 301, remainder is 0 > 301/2 = 150, remainder is 1 > 150/2 = 75, remainder is 0 > 75/2 = 37, remainder is 1 > 37/2 = 18, remainder is 1 > 18/2 = 9, remainder is 0 > 9/2 = 4, remainder is 1 > 4/2 = 2, remainder is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 100101101011010011010 So, 1234586 of decimal is 100101101011010011010 in binary > Now, Convert 0.8999999999068677 to binary > Multiply 0.8999999999068677 with 2. Since 1.7999999998137355 is >= 1. then add 1 to result > Multiply 0.7999999998137355 with 2. Since 1.599999999627471 is >= 1. then add 1 to result > Multiply 0.599999999627471 with 2. Since 1.199999999254942 is >= 1. then add 1 to result > Multiply 0.19999999925494194 with 2. Since 0.3999999985098839 is < 1. then add 0 to result > Multiply 0.3999999985098839 with 2. Since 0.7999999970197678 is < 1. then add 0 to result > Multiply 0.7999999970197678 with 2. Since 1.5999999940395355 is >= 1. then add 1 to result > This is equal to 1, so, stop calculating 0.8999999999068677 of decimal is .111001 in binary so, 1234586.9 in binary is 100101101011010011010.111001 1234586.9 in simple binary => 100101101011010011010.111001 so, 1234586.9 in normal binary is 100101101011010011010.111001 => 1.00101101011010011010111 * 2^20 single precision: -------------------- sign bit is 0(+ve) exp bits are (127+20=147) => 10010011 Divide 147 successively by 2 until the quotient is 0 > 147/2 = 73, remainder is 1 > 73/2 = 36, remainder is 1 > 36/2 = 18, remainder is 0 > 18/2 = 9, remainder is 0 > 9/2 = 4, remainder is 1 > 4/2 = 2, remainder is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 10010011 So, 147 of decimal is 10010011 in binary frac bits are 00101101011010011010111 so, 1234586.9 in single-precision format is 0 10010011 00101101011010011010111 in hexadecimal it is 0x4996B4D7