Hi I am trying to convert the hex value into float the method I am using is
function hex2float($strHex) {
$hex = sscanf($strHex, "%02x%02x%02x%02x%02x%02x%02x%02x");
$hex = array_reverse($hex);
$bin = implode('', array_map('chr', $hex));
$array = unpack("dnum", $bin);
return $array['num'];
}
$float = hex2float('4019999a');
echo $float;
Output
The output it's returning is 6.4000015258789
but in actual it should be 2.4
See reference