I've got a few variables stored in an object that (for purposes of troubleshooting) I am extracting and turning into floats for comparison. For some reason some PHP is not considering some of the properties as equal (when they are by all appearances) whether or not I directly compare the properties, extract them, or compare their float value:
$lat1 = $coordinates1->latitude; $lat2 = $coordinates2->latitude;
$lon1 = $coordinates1->longitude; $lon2 = $coordinates2->longitude;
if (floatval($lat1) == floatval($lat2)) {
$myLog->debug("[".floatval($lat1)."] == [".floatval($lat2)."]");
} else {
$myLog->debug("[".floatval($lat1)."] != [".floatval($lat2)."]");
}
if (floatval($lon1) == floatval($lon2)) {
$myLog->debug("[".floatval($lon1)."] == [".floatval($lon2)."]");
} else {
$myLog->debug("[".floatval($lon1)."] != [".floatval($lon2)."]");
}
The results in the debug log are as follows for two different sets of values:
[42.398264] != [42.442251]
[-83.316297] != [-83.33669]
[42.398264] == [42.398264]
[-83.316297] != [-83.316297]
What am I missing?