I need to convert NSDecimalNumber with lat/lon values which I need to convert to CLLocationDegrees. I used -[NSDecimalNumber doubleValue] method. But the value loses its precision. I want the values to be same. The following is what I am talking about(I hope everyone would be aware about this issue already).
NSString *coordStr = @"-33.890934125621094";
NSDecimalNumber *lat = [NSDecimalNumber decimalNumberWithString:coordStr];
NSLog(@"%@", lat); // -33.890934125621094
NSLog(@"%lf", [lat doubleValue]); // -33.890934
Is there any way that I should do instead of doing the above?
Try out to convert the String with the
doubleValuemethodCheck out this post: How to print a double with full precision on iOS?
edit:
the docu says:
typedef double CLLocationDegrees;so you candouble test = coordStr.doubleValue;the problem is only, thatNSLogdoesn’t print the complete value. but instead the double var saves the complete value.