Monday 9 November 2020

How to store exact digits in Firestore

How do I store exact values for numbers in Firestore from the Objective-C SDK?

For instance, if I manually create a field called "abv" with a value of "15.9" it shows that exact value.

enter image description here

However, if I update a value in Firestore from the Objective-C API with an NSNumber value of @(15.9) I get this imprecise value in my Firestore document.

enter image description here

NSDictionary *data = @{@"abv": @(15.9)};
[documentReference updateData:data completion:^(NSError * _Nullable error) {

}];

I understand the issues around floating point imprecision but I don't know how to communicate it in a way to Firebase that resolves it like when you do a manual edit from the web console such as store "15.9" exactly as a number.



from How to store exact digits in Firestore

No comments:

Post a Comment