In: Computer Science
Assume that you have a 12-bit floating point number system, similar to the IEEE floating point standard, with the format shown below and a bias of 7. The value of a floating point number in this system is represented as
FP = (-1)^S X 1.F X 2^(E-bias)
for the floating point numbers A = 8.75 and B = -5.375. The binary representation of A is given as
A = 0101 0000 1100
Show the hexidecimal representation of B.
0xCAC Explanation: ------------- -5.375 Converting 5.375 to binary Convert decimal part first, then the fractional part > First convert 5 to binary Divide 5 successively by 2 until the quotient is 0 > 5/2 = 2, remainder is 1 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 101 So, 5 of decimal is 101 in binary > Now, Convert 0.37500000 to binary > 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.375 of decimal is .011 in binary so, 5.375 in binary is 00000101.011 -5.375 in simple binary => 101.011 so, -5.375 in normal binary is 101.011 => 1.01011 * 2^2 12-bit format: -------------------- sign bit is 1(-ve) exponent bits are (7+2=9) => 1001 Divide 9 successively by 2 until the quotient 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 1001 So, 9 of decimal is 1001 in binary frac/significant bits are 0101100 so, -5.375 in 12-bit format is 1 1001 0101100 Hexadecimal Binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111 Use this table to convert from binary to hexadecimal Converting 110010101100 to hexadecimal 1100 => C 1010 => A 1100 => C So, in hexadecimal 110010101100 is 0xCAC in hexadecimal it is 0xCAC