<?php
$lat1 = 35.697959;
$lat2 = 35.697959;
$lon1 = 139.707085;
$lon2 = 139.707085;
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
var_dump($dist); // returns 1
$dist = acos(min(max($dist,-1.0),1.0));
var_dump($dist); // returns NAN
$x = 1;
$x = acos($x);
var_dump($x); // doesn't return NAN
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1 - 8.4.2
- float(1.0000000000000002)
float(0)
float(0)
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
- float(1)
float(0)
float(0)
preferences:
57.46 ms | 408 KiB | 5 Q