What is the function of this use of floating-point arithmetic in PHP?
Please take a look at the example of floating point arithmetic in Baidu Encyclopedia first
Http://wenku.baidu.com/view/9ba120a108a1284ac85043d8.html?re=view
The hexadecimal 42c88000.
Use the IEEE754 standard 32-bit floating-point number format to calculate the result equals 100.25
To figure out the hexadecimal c1c90000 is 25.125.
Are there any existing functions?
Write an example for me, thank you very much.
Thank you
Reply to discussion (solution)
equals 100.25
$s = ' 42c88000 '; Echo current (Unpack (' F ', pack (' V ', Hexdec ($s))));
100.25
$s = ' c1c90000 '; Echo current (Unpack (' F ', pack (' V ', Hexdec ($s))));
-25.125
can also
$s = ' c1c90000 '; Echo current (Unpack (' F ', pack (' h* ', join (', Array_reverse (Str_split ($s, 2)))));
-25.125
#1 code is valid only for positive numbers
$a = ' c1c90000 '; echo hextodecfloat ($a);
-6.875
needs to be perfected
Thank you moderator for your help.