You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The root issue is that Float64.from_json tries to obtain the floating-point value from 43474709000000132 / 1e15, which in turn calls 43474709000000132.to_f64 / 1e15.to_f64. The significand is inexact and rounds off to 43474709000000128.0 (it is halfway between this value and 43474709000000136.0, and the ties-to-even rule chooses this value), so the division becomes inexact. If you do the same division in other programming languages you could get the same incorrect results.
Repro steps
Below code show difference between from_json and to_f64. (result of to_f64 is consistent with other languages while from_json is not)
Crystal compiler version
The text was updated successfully, but these errors were encountered: