Rhymond/go-money

NewFromFloat trouble

Opened this issue · 3 comments

Why is the float64 value equal to 1.15 created in the money type as 1.14?
The link below shows an example of the supposed error:
https://go.dev/play/p/Z64XrP8LdTc

@jasonharrison, you could use decimal to fix this problem
https://go.dev/play/p/HUMiR2-5AOb

I have the same issue.

@jasonharrison, you could use decimal to fix this problem https://go.dev/play/p/HUMiR2-5AOb

@vivl4725
I guess this solution doesn't make sense for those who want to use go-money.

The problem is that the binary representation of 1.15 is closer to 114.99999999999999

This can solved by adding a small "epsilon" value to the parsed value.