I'm using the CLLocationManager in Swift. When I display location.coordinate, it provides me with the result:
37.787358900000001, longitude: -122.408227
However, if I display. location.coordinate.latitude, the result is
37.7873589
Do you know how I can get all the decimals?
Thanks, Thomas
You are seeing
37.787358900000001instead of37.7873589because of the nature of representing floating point numbers in a computer.That said, it is pointless to worry about decimal places beyond the 6th position because even changing the
9to an8would result in a change of about1centimeter. The GPS system is currently accurate to about +/- 5 meters, and with new chips being deployed by Broadcom that can be reduced to about +/- 30 centimeters in the near future.Altitude calculations are done by computing the distance to the visible GPS satellites which orbit the Earth every 12 hours. Since the satellites are constantly moving, and different satellites come into view, these calculations do tend to fluctuate. This article though a bit dated is enlightening.