In: Computer Science
Convert 2.115 single-precision floating point binary format. Please show every single detail for upvote. Please do not answer otherwise.
Converting 2.115 to binary Convert decimal part first, then the fractional part > First convert 2 to binary Divide 2 successively by 2 until the quotient is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 10 So, 2 of decimal is 10 in binary > Now, Convert 0.11500000000000021 to binary > Multiply 0.11500000000000021 with 2. Since 0.23000000000000043 is < 1. then add 0 to result > Multiply 0.23000000000000043 with 2. Since 0.46000000000000085 is < 1. then add 0 to result > Multiply 0.46000000000000085 with 2. Since 0.9200000000000017 is < 1. then add 0 to result > Multiply 0.9200000000000017 with 2. Since 1.8400000000000034 is >= 1. then add 1 to result > Multiply 0.8400000000000034 with 2. Since 1.6800000000000068 is >= 1. then add 1 to result > Multiply 0.6800000000000068 with 2. Since 1.3600000000000136 is >= 1. then add 1 to result > Multiply 0.36000000000001364 with 2. Since 0.7200000000000273 is < 1. then add 0 to result > Multiply 0.7200000000000273 with 2. Since 1.4400000000000546 is >= 1. then add 1 to result > Multiply 0.44000000000005457 with 2. Since 0.8800000000001091 is < 1. then add 0 to result > Multiply 0.8800000000001091 with 2. Since 1.7600000000002183 is >= 1. then add 1 to result > Multiply 0.7600000000002183 with 2. Since 1.5200000000004366 is >= 1. then add 1 to result > Multiply 0.5200000000004366 with 2. Since 1.0400000000008731 is >= 1. then add 1 to result > Multiply 0.040000000000873115 with 2. Since 0.08000000000174623 is < 1. then add 0 to result > Multiply 0.08000000000174623 with 2. Since 0.16000000000349246 is < 1. then add 0 to result > Multiply 0.16000000000349246 with 2. Since 0.3200000000069849 is < 1. then add 0 to result > Multiply 0.3200000000069849 with 2. Since 0.6400000000139698 is < 1. then add 0 to result > Multiply 0.6400000000139698 with 2. Since 1.2800000000279397 is >= 1. then add 1 to result > Multiply 0.2800000000279397 with 2. Since 0.5600000000558794 is < 1. then add 0 to result > Multiply 0.5600000000558794 with 2. Since 1.1200000001117587 is >= 1. then add 1 to result > Multiply 0.12000000011175871 with 2. Since 0.24000000022351742 is < 1. then add 0 to result > Multiply 0.24000000022351742 with 2. Since 0.48000000044703484 is < 1. then add 0 to result > Multiply 0.48000000044703484 with 2. Since 0.9600000008940697 is < 1. then add 0 to result > Multiply 0.9600000008940697 with 2. Since 1.9200000017881393 is >= 1. then add 1 to result > Multiply 0.9200000017881393 with 2. Since 1.8400000035762787 is >= 1. then add 1 to result > Multiply 0.8400000035762787 with 2. Since 1.6800000071525574 is >= 1. then add 1 to result > Multiply 0.6800000071525574 with 2. Since 1.3600000143051147 is >= 1. then add 1 to result > Multiply 0.36000001430511475 with 2. Since 0.7200000286102295 is < 1. then add 0 to result > Multiply 0.7200000286102295 with 2. Since 1.440000057220459 is >= 1. then add 1 to result > Multiply 0.440000057220459 with 2. Since 0.880000114440918 is < 1. then add 0 to result > Multiply 0.880000114440918 with 2. Since 1.760000228881836 is >= 1. then add 1 to result > Multiply 0.7600002288818359 with 2. Since 1.5200004577636719 is >= 1. then add 1 to result > Multiply 0.5200004577636719 with 2. Since 1.0400009155273438 is >= 1. then add 1 to result > Multiply 0.04000091552734375 with 2. Since 0.0800018310546875 is < 1. then add 0 to result > Multiply 0.0800018310546875 with 2. Since 0.160003662109375 is < 1. then add 0 to result > Multiply 0.160003662109375 with 2. Since 0.32000732421875 is < 1. then add 0 to result > Multiply 0.32000732421875 with 2. Since 0.6400146484375 is < 1. then add 0 to result > Multiply 0.6400146484375 with 2. Since 1.280029296875 is >= 1. then add 1 to result > Multiply 0.280029296875 with 2. Since 0.56005859375 is < 1. then add 0 to result > Multiply 0.56005859375 with 2. Since 1.1201171875 is >= 1. then add 1 to result > Multiply 0.1201171875 with 2. Since 0.240234375 is < 1. then add 0 to result > Multiply 0.240234375 with 2. Since 0.48046875 is < 1. then add 0 to result > Multiply 0.48046875 with 2. Since 0.9609375 is < 1. then add 0 to result > Multiply 0.9609375 with 2. Since 1.921875 is >= 1. then add 1 to result > Multiply 0.921875 with 2. Since 1.84375 is >= 1. then add 1 to result > Multiply 0.84375 with 2. Since 1.6875 is >= 1. then add 1 to result > Multiply 0.6875 with 2. Since 1.375 is >= 1. then add 1 to result > Multiply 0.375 with 2. Since 0.75 is < 1. then add 0 to result > Multiply 0.75 with 2. Since 1.5 is >= 1. then add 1 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.11500000000000021 of decimal is .0001110101110000101000111101011100001010001111011 in binary so, 2.115 in binary is 10.0001110101110000101000111101011100001010001111011 2.115 in simple binary => 10.0001110101110000101000111101011100001010001111011 so, 2.115 in normal binary is 10.0001110101110000101000111101011100001010001111011 => 1.00001110101110000101 * 2^1 single precision: -------------------- sign bit is 0(+ve) exp bits are (127+1=128) => 10000000 Divide 128 successively by 2 until the quotient is 0 > 128/2 = 64, remainder is 0 > 64/2 = 32, remainder is 0 > 32/2 = 16, remainder is 0 > 16/2 = 8, remainder is 0 > 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 10000000 So, 128 of decimal is 10000000 in binary frac bits are 00001110101110000101000 so, 2.115 in single-precision format is 0 10000000 00001110101110000101000 in hexadecimal it is 0x40075C28