In: Computer Science
Convert -99.999 into double precision floating format
show all steps and explanations
Converting 99.999 to binary Convert decimal part first, then the fractional part > First convert 99 to binary Divide 99 successively by 2 until the quotient is 0 > 99/2 = 49, remainder is 1 > 49/2 = 24, remainder is 1 > 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 1100011 So, 99 of decimal is 1100011 in binary > Now, Convert 0.99900000 to binary > Multiply 0.99900000 with 2. Since 1.99800000 is >= 1. then add 1 to result > Multiply 0.99800000 with 2. Since 1.99600000 is >= 1. then add 1 to result > Multiply 0.99600000 with 2. Since 1.99200000 is >= 1. then add 1 to result > Multiply 0.99200000 with 2. Since 1.98400000 is >= 1. then add 1 to result > Multiply 0.98400000 with 2. Since 1.96800000 is >= 1. then add 1 to result > Multiply 0.96800000 with 2. Since 1.93600000 is >= 1. then add 1 to result > Multiply 0.93600000 with 2. Since 1.87200000 is >= 1. then add 1 to result > Multiply 0.87200000 with 2. Since 1.74400000 is >= 1. then add 1 to result > Multiply 0.74400000 with 2. Since 1.48800000 is >= 1. then add 1 to result > Multiply 0.48800000 with 2. Since 0.97600000 is < 1. then add 0 to result > Multiply 0.97600000 with 2. Since 1.95200000 is >= 1. then add 1 to result > Multiply 0.95200000 with 2. Since 1.90400000 is >= 1. then add 1 to result > Multiply 0.90400000 with 2. Since 1.80800000 is >= 1. then add 1 to result > Multiply 0.80800000 with 2. Since 1.61600000 is >= 1. then add 1 to result > Multiply 0.61600000 with 2. Since 1.23200000 is >= 1. then add 1 to result > Multiply 0.23200000 with 2. Since 0.46400000 is < 1. then add 0 to result > Multiply 0.46400000 with 2. Since 0.92800000 is < 1. then add 0 to result > Multiply 0.92800000 with 2. Since 1.85600000 is >= 1. then add 1 to result > Multiply 0.85600000 with 2. Since 1.71200000 is >= 1. then add 1 to result > Multiply 0.71200000 with 2. Since 1.42399999 is >= 1. then add 1 to result > Multiply 0.42399999 with 2. Since 0.84799999 is < 1. then add 0 to result > Multiply 0.84799999 with 2. Since 1.69599998 is >= 1. then add 1 to result > Multiply 0.69599998 with 2. Since 1.39199996 is >= 1. then add 1 to result > Multiply 0.39199996 with 2. Since 0.78399992 is < 1. then add 0 to result > Multiply 0.78399992 with 2. Since 1.56799984 is >= 1. then add 1 to result > Multiply 0.56799984 with 2. Since 1.13599968 is >= 1. then add 1 to result > Multiply 0.13599968 with 2. Since 0.27199936 is < 1. then add 0 to result > Multiply 0.27199936 with 2. Since 0.54399872 is < 1. then add 0 to result > Multiply 0.54399872 with 2. Since 1.08799744 is >= 1. then add 1 to result > Multiply 0.08799744 with 2. Since 0.17599487 is < 1. then add 0 to result > Multiply 0.17599487 with 2. Since 0.35198975 is < 1. then add 0 to result > Multiply 0.35198975 with 2. Since 0.70397949 is < 1. then add 0 to result > Multiply 0.70397949 with 2. Since 1.40795898 is >= 1. then add 1 to result > Multiply 0.40795898 with 2. Since 0.81591797 is < 1. then add 0 to result > Multiply 0.81591797 with 2. Since 1.63183594 is >= 1. then add 1 to result > Multiply 0.63183594 with 2. Since 1.26367188 is >= 1. then add 1 to result > Multiply 0.26367188 with 2. Since 0.52734375 is < 1. then add 0 to result > Multiply 0.52734375 with 2. Since 1.05468750 is >= 1. then add 1 to result > Multiply 0.05468750 with 2. Since 0.10937500 is < 1. then add 0 to result > Multiply 0.10937500 with 2. Since 0.21875000 is < 1. then add 0 to result > Multiply 0.21875000 with 2. Since 0.43750000 is < 1. then add 0 to result > Multiply 0.43750000 with 2. Since 0.87500000 is < 1. then add 0 to result > Multiply 0.87500000 with 2. Since 1.75000000 is >= 1. then add 1 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.9989999999999952 of decimal is .111111111011111001110110110010001011010000111 in binary so, 99.999 in binary is 1100011.111111111011111001110110110010001011010000111 -99.999 in simple binary => 1100011.111111111011111001110110110010001011010000111 so, -99.999 in normal binary is 1100011.111111111011111001110110110010001011010000111 => 1.100011111111111011111001110110110010001011010000111 * 2^6 single precision: -------------------- sign bit is 1(-ve) exp bits are (1023+6=1029) => 10000000101 Divide 1029 successively by 2 until the quotient is 0 > 1029/2 = 514, remainder is 1 > 514/2 = 257, remainder is 0 > 257/2 = 128, remainder is 1 > 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 10000000101 So, 1029 of decimal is 10000000101 in binary frac bits are 1000111111111110111110011101101100100010110100001110 so, -99.999 in single-precision format is 1 10000000101 1000111111111110111110011101101100100010110100001110 in hexadecimal it is 0xC058FFEF9DB22D0E