How to store exact digits in Firestore

This solved the issue by using NSDecimalNumber. I can store numbers exactly now with two decimal precision.

NSNumber *number = (NSNumber *)value;
NSString *text = [NSString stringWithFormat:@"%.2f", number.doubleValue];
NSDecimalNumber *decimalNumber = [[NSDecimalNumber alloc] initWithString:text];
return decimalNumber;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top