Pure decimal representation
-------------------------------------------------
Next we will explain how to convert a pure decimal number to a hexadecimal number. For a pure decimal number, such as 0.0456, We need to normalize it to the type of 1. xxxx * (2 ^ n). The following formula is required for the n corresponding to the pure decimal number X:
N = int (-1 + Log (2) X );
0.0456 is expressed as 1.4592 multiplied by the power of-5 to the base of 2 (0.0456/(2 ^-5) = 1.4592), that is, 1.4592*(2 ^-5 ). After being converted to this form, follow the process in the second example above:
01110101100011100010001.
Remove the first 1
01110101100011100010001
-5 + 127 = 122
0 01111010 01110101100011100010001
Finally:
11 C7 3A 3D
In addition, we have to mention that the hexadecimal value of 0.0f is 00 00 00. Remember this.
See http://blog.sina.com.cn/s/blog_54ad678901014sq2.html
IEEE floating point representation of decimal places