Open Natim opened 4 years ago
I believe this is a duplicate of #165, isn't it?
Yes but #165 was closed while we are still using float. And as you well know, we have a couple more bugs with the external lib too.
More interesting research here: https://ren.zone/articles/safe-money
Yes, you're right : we should move away from these silly floats!
Hey @Natim ! Are you sure you want to store integers ? After reading your article we might want to store it as decimal string: https://docs.python.org/3/library/decimal.html and do operations with fractions: https://docs.python.org/3/library/fractions.html What do you think about this ?
Yes you are exactly right.
@LeoMouyna how do you plan on serializing Fraction('1.1') + Fraction('0.3') + Fraction(100 ,3)
? as a (521, 15)
tuple?
Storing bills as floats leads to a number of problematic edge cases.
Instead we should handle money as integers in cents and then display them as float in the end.
We did this change on the elm-ihatemoney project during yesterday hackathon with @gdeest and I think we should fix it in the API as well.