These kinds of differences are not enough to be worried about in most situations.
Floating point numbers are notorious for being slightly off of the intended values because of the number of bits and how floating point numbers are stored in binary. For example, as demonstrated here, a decimal value of 0.1
has an actual double
value of 0.10000000149011612
. Close, but not exact.
A technique I've seen used in some applications that need absolutely accurate latitude and longitude numbers is that they'll keep the values in integral data types that are equivalent to the float multiplied by some power of 10. For example, a GeoPoint in the Google Maps API v1 on Android measures in micro degrees. Instead of a latitude and longitude like 54.123428, 60.809234
to preserve the values precisely they'd be ints: 54123428, 60809234
. To depict this, they'd call the variables latitudeE6
and longitudeE6
to indicate that it's the real latitude or longitude multiplied by 1E6 (the scientific notation of 10^6).