In: Computer Science
Convert −98765.4321 to IEEE 745 (show your work)
Converting 98765.4321 to binary Convert decimal part first, then the fractional part > First convert 98765 to binary Divide 98765 successively by 2 until the quotient is 0 > 98765/2 = 49382, remainder is 1 > 49382/2 = 24691, remainder is 0 > 24691/2 = 12345, remainder is 1 > 12345/2 = 6172, remainder is 1 > 6172/2 = 3086, remainder is 0 > 3086/2 = 1543, remainder is 0 > 1543/2 = 771, remainder is 1 > 771/2 = 385, remainder is 1 > 385/2 = 192, remainder is 1 > 192/2 = 96, remainder is 0 > 96/2 = 48, remainder is 0 > 48/2 = 24, remainder is 0 > 24/2 = 12, remainder is 0 > 12/2 = 6, remainder is 0 > 6/2 = 3, remainder is 0 > 3/2 = 1, remainder is 1 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 11000000111001101 So, 98765 of decimal is 11000000111001101 in binary > Now, Convert 0.43210000000544824 to binary > Multiply 0.43210000000544824 with 2. Since 0.8642000000108965 is < 1. then add 0 to result > Multiply 0.8642000000108965 with 2. Since 1.728400000021793 is >= 1. then add 1 to result > Multiply 0.728400000021793 with 2. Since 1.456800000043586 is >= 1. then add 1 to result > Multiply 0.4568000000435859 with 2. Since 0.9136000000871718 is < 1. then add 0 to result > Multiply 0.9136000000871718 with 2. Since 1.8272000001743436 is >= 1. then add 1 to result > Multiply 0.8272000001743436 with 2. Since 1.6544000003486872 is >= 1. then add 1 to result > Multiply 0.6544000003486872 with 2. Since 1.3088000006973743 is >= 1. then add 1 to result > Multiply 0.30880000069737434 with 2. Since 0.6176000013947487 is < 1. then add 0 to result > Multiply 0.6176000013947487 with 2. Since 1.2352000027894974 is >= 1. then add 1 to result > Multiply 0.23520000278949738 with 2. Since 0.47040000557899475 is < 1. then add 0 to result > Multiply 0.47040000557899475 with 2. Since 0.9408000111579895 is < 1. then add 0 to result > Multiply 0.9408000111579895 with 2. Since 1.881600022315979 is >= 1. then add 1 to result > Multiply 0.881600022315979 with 2. Since 1.763200044631958 is >= 1. then add 1 to result > Multiply 0.763200044631958 with 2. Since 1.526400089263916 is >= 1. then add 1 to result > Multiply 0.526400089263916 with 2. Since 1.052800178527832 is >= 1. then add 1 to result > Multiply 0.05280017852783203 with 2. Since 0.10560035705566406 is < 1. then add 0 to result > Multiply 0.10560035705566406 with 2. Since 0.21120071411132812 is < 1. then add 0 to result > Multiply 0.21120071411132812 with 2. Since 0.42240142822265625 is < 1. then add 0 to result > Multiply 0.42240142822265625 with 2. Since 0.8448028564453125 is < 1. then add 0 to result > Multiply 0.8448028564453125 with 2. Since 1.689605712890625 is >= 1. then add 1 to result > Multiply 0.689605712890625 with 2. Since 1.37921142578125 is >= 1. then add 1 to result > Multiply 0.37921142578125 with 2. Since 0.7584228515625 is < 1. then add 0 to result > Multiply 0.7584228515625 with 2. Since 1.516845703125 is >= 1. then add 1 to result > Multiply 0.516845703125 with 2. Since 1.03369140625 is >= 1. then add 1 to result > Multiply 0.03369140625 with 2. Since 0.0673828125 is < 1. then add 0 to result > Multiply 0.0673828125 with 2. Since 0.134765625 is < 1. then add 0 to result > Multiply 0.134765625 with 2. Since 0.26953125 is < 1. then add 0 to result > Multiply 0.26953125 with 2. Since 0.5390625 is < 1. then add 0 to result > Multiply 0.5390625 with 2. Since 1.078125 is >= 1. then add 1 to result > Multiply 0.078125 with 2. Since 0.15625 is < 1. then add 0 to result > Multiply 0.15625 with 2. Since 0.3125 is < 1. then add 0 to result > Multiply 0.3125 with 2. Since 0.625 is < 1. then add 0 to result > Multiply 0.625 with 2. Since 1.25 is >= 1. then add 1 to result > Multiply 0.25 with 2. Since 0.5 is < 1. then add 0 to result > Multiply 0.5 with 2. Since 1.0 is >= 1. then add 1 to result > This is equal to 1, so, stop calculating 0.43210000000544824 of decimal is .01101110100111100001101100001000101 in binary so, 98765.4321 in binary is 11000000111001101.01101110100111100001101100001000101 -98765.4321 in simple binary => 11000000111001101.01101110100111100001101100001000101 so, -98765.4321 in normal binary is 11000000111001101.01101110100111100001101100001000101 => 1.10000001110011010110111 * 2^16 single precision: -------------------- sign bit is 1(-ve) exp bits are (127+16=143) => 10001111 Divide 143 successively by 2 until the quotient is 0 > 143/2 = 71, remainder is 1 > 71/2 = 35, remainder is 1 > 35/2 = 17, remainder is 1 > 17/2 = 8, remainder is 1 > 8/2 = 4, remainder is 0 > 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 10001111 So, 143 of decimal is 10001111 in binary frac bits are 10000001110011010110111 so, -98765.4321 in single-precision format is 1 10001111 10000001110011010110111 in hexadecimal it is 0xC7C0E6B7