Skip to main content

When I use the price string from the API, we see 12.99 like we have in the Apple app store. However, when I access the price itself in the Flutter client library, I see 12.989999771118164. I am not manipulating this price at all, I am printing it directly from Flutter lib. Do you think this is: 1) Apple weirdness 2) RevenueCat API bug OR 3) Flutter bug?

This is due to the nature of floating point decimals. More info in this Stackoverflow post here: https://stackoverflow.com/questions/21895756/why-are-floating-point-numbers-inaccurate

Rounding the float to 2 decimals should land you with the correct formatted currency. There may be some enhancement we could do in the SDK to improve how these are displayed. @taquitos knows more about floating point accuracy than me...


Rounding something like 5.999 even to 2 decimals takes you to “6” so it won’t always work. Maybe in this case though


Rounding something like 5.999 even to 2 decimals takes you to “6” so it won’t always work. Maybe in this case though

I don’t think you would run into that, since $5.99, converted to a float should still round back to $5.99. If it was $6.00 then you could see a case of 5.9999 or 6.0001.


I’m 3 years late, but a search showed this thread.

I have more or less the same issue. My 19.99 subscription shows as 19.98999999… I know about the float issue, but how can I fix this?

I found this, but how is it used?
https://github.com/RevenueCat/purchases-ios/pull/4132

Thanks,


Reply