Saving coordinates from the primary location to the reference data. Float or Double?

I saw both options that people use ... I just don’t know if float is enough for iOS5?

+8
ios5 core-data core-location
source share
4 answers

A 32-bit float contains 7 precision digits, a 64-bit double contains 15 precision digits.

With 7 digits of accuracy, the maximum longitude of 179.9999 is only accurate to 0.0001 degrees. The degree is about 60 nautical miles, so 0.0001 degrees is about 10 meters (33 feet). If you want to keep more accurate lat / lon values, you need to use a double (or a fixed-point integer).

+21
source share

These days it does not really matter.

Double is just a floating point slot that can hold twice as much accuracy as a standard float. If you do not force it to use float, the Objective-c compiler will actually save all float values ​​as double.

Floats and paired pairs are largely held back from the old days when memory was very hard. These days, you usually see that they are different when it comes to formatting strings. This is the same with different int sizes. All sizes are stored in the largest available size, unless you force the compiler to do otherwise.

+3
source share

To answer what precision you use when using float or double, I came up with this answer:

Worst case accuracy when stored as decimal numbers for E / W and N / S:

  • float: 1.6955566 meters
  • double: 3.1582203519064933E-9 meters. (This is 3 nm)

You can do the calculations yourself by doing 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 a problem. A float is most likely enough for most applications. The GPS device of the Apple device in question probably does not have a higher accuracy than this. But storing duplicates is easier as long as the data is not a problem.

+2
source share

Recently, I find it easy to save the coordinate in Core Data as NSValue in a transformable attribute:

 [NSValue valueWithMKCoordinate:coordinate] 

https://developer.apple.com/library/ios/documentation/MapKit/Reference/NSValue_MapKit_additions/Reference/Reference.html

+2
source share

All Articles