Java: Trigonometry and double inaccuracy causing NaN
问题 I have a distance formula using latitude and longitude: distance = EARTH_MILES_RADIUS * Math.acos(Math.sin(lat1 / RADIAN_CONV) * Math.sin(lat2 / RADIAN_CONV) + Math.cos(lat1 / RADIAN_CONV) * Math.cos(lat2 / RADIAN_CONV) * Math.cos((lng2 - lng1) / RADIAN_CONV)); lat1,lng1,lat2,lng2 are double primitives. They come to me as double primitives and there is nothing I can do about it. The problem is that when I have a pair of longitude or latitudes that are the same the formula sometimes returns