In: Computer Science
I have the following decimal value 17.25. How can i convert this to IEEE 754 32 bit single precision floating point and double precision?. I need to use this as a matlab function block in Simulink, therefore i cannot use the conversion of hexadecimal to IEEE 754 32 bit single precision floating point matlab script.
To convert a decimal number to IEEE 754 format , first of all the number has to be converted to binary form. As shown in the figure, the two part of the number i.e, before the decimal point and after the decimal point has to be converted separately.
IEEE 754 floating point representation can be done in two ways: single precision and double precision. The two formats are shown below
A binary number can be represented in 32 bit single precision or 64 bit double precision.To convert in single precision we follow the steps described below.
1.After evaluating the binary equivalent, the decimal point has to moved to the left most side to reach the left most position of 1, to reach 1 the decimal point has to moved 4 steps as shown below, as it has taken 4 steps left the exponent has to raised to the power of 2 ( here 2 is considered as the number is binary), so 24 has become the exponent. Thus the exponent is calculated by adding 4 to 127 which is the bias exponent of single precision ( bias exponent of double precision is 1053). 4+127 is 131 , binary equivalent is found out i.e, 10000011
2. For mantissa, it is shown below, and the sign bit is 0 as the number is positive number.
For double precision format all the steps are similar , only the exponent bias is 1053 wich is added and the mantissa have 52 bits as shown above.
Hope it helped