Qqwy/elixir-rational

Weird rounding error when applying percantage.

Closed this issue · 2 comments

Hajto commented
value = Ratio.new(625097671600000) 
percentage = Ratio.new(0.5)

value |> Ratio.mult(percentage) |> Ratio.ceil()
312548835800001

Where the expected result would be 312548835800000 because the number is already an integer.

The same with Ratio.new(400) |> Ratio.ceil(), should be 400 but the output is 401.