I am working with php and I get some coordinates in hexadecimal format (this can not be changed because it is a message that is received from the SigFox network). The values that are received are C40B3986
and 4564AF79
and the values in float would be -556.8988
and 3658.967
. I used this code that I found by google to do the transformation:
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'];
}
But the results obtained differ considerably from what was expected: 2.9704245515207E-65
and 6.7994010560009E-225
. Can someone help me out?