I saw both variants people use... Just don't know is float not enough for iOS5?
A 32-bit float holds 7 digits of precision, a 64-bit double holds 15 digits of precision.
With 7 digits of precision the maximum longitude of 179.9999 is only accurate down to 0.0001 degrees. A degree is about 60 nautical miles so 0.0001 degrees is about 10 meters (33 feet). If you want to store more precise lat/lon values, then you need to use a double (or a fixed point integer).
These days it doesn't matter much.
A double is just a float value slot that can hold twice as much precision as a standard float. Unless you force it to use a float, the Objective-c compiler will actually store all float values as a double.
Floats and Doubles are largely hold overs from the old days when memory was super tight. These days, you usually only see them different when it comes to string formatting. It's the same with various sizes of int. All sizes are stored in the largest available size unless you force the compiler to do otherwise.
For answering which accuracy you have when using floats or double I have come up with this answer:
Worst case accuracy when storing as decimal numbers for E/W and N/S:
You can do the calculations yourself by running this in Java:
public class Main {
public static void main(String[] args) {
System.out.println(Math.ulp((float) 180) * 60 * 1852);
System.out.println(Math.ulp((double) 180) * 60 * 1852);
}
}
I know this is an old thread but I found it while searching for the problem. Float is most probably enough for most applications. The GPS of the Apple device in question does probably not have better accuracy than that. But it is easier to store doubles as long as data is not a concern.
Recently, I think it's just easier to store coordinate in Core Data as NSValue
in transformable attribute:
[NSValue valueWithMKCoordinate:coordinate]
https://developer.apple.com/documentation/foundation/nsvalue/1452193-valuewithmkcoordinate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With