We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to convert the hex float value in memory into decimal,such as 42F94000H=124.75,which 42F94000H is the hex value,and how can I implement the decimal 124.75 using program,or other cases?
Other than using a library routine - where would be the fun in that - you will need to write your own code. This should get you started. First, you need to understand how floating point values are represented. See: http://www.ahpcc.unm.edu/~acpineda/CS471/HTML/ieeeflpt/ The 32-bit value you have in hex is divided into three fields. The first field is of one bit and indicates the sign of the value. The second field is of eight bits and indicates the exponent plus 127 and the remainder is the fractional part with an implied one as an extra most-significant bit.
42F94000 = 0100 0010 1111 1001 0100 0000 0000 0000 || || | || |+-------fraction-----------+ |+exponent+ +sign sign = 0 indicating positive value. exponent = 10000101 = 133. 133-127=6 fraction = 111 1001 0100 0000 0000 0000
0000 0000 0111 1001 0100 0000 0000 0000
0000 0000 0000 0000.1111 0010 1000 0000
0000 0000 0000 0001.1111 0010 1000 0000
0000 0000 0111 1100.1010 0000 0000 0000
I meant to say, I make it 124.625.