We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently this uses floats to perform arithmetic, which leads to unexpected evals over certain numerical intersections
This test currently passes, but most people's general conceptions would expect this to fail
test "floating point arithmetic" do refute JsonLogic.apply(%{"+" => [0.1, 0.2]}) == 0.3 assert JsonLogic.apply(%{"+" => [0.1, 0.2]}) == 0.30000000000000004 end
The text was updated successfully, but these errors were encountered:
I tried to put this in to fix it but there are some guards clauses that break, so it'll need to have individual methods looked at:
import Kernel, except: [ {:+, 2}, {:-, 2}, {:/, 2}, {:*, 2}, {:==, 2}, {:!=, 2}, {:>, 2}, {:<, 2}, {:>=, 2}, {:<=, 2} ] def x + y do x |> Decimal.add(y) |> Decimal.to_float() end def x - y do x |> Decimal.sub(y) |> Decimal.to_float() end def x * y do x |> Decimal.mult(y) |> Decimal.to_float() end def x / y do x |> Decimal.div(y) |> Decimal.to_float() end def x == y do Decimal.equals?(x, y) end def x != y do not Decimal.equals?(x, y) end def x >= y do Decimal.gt?(x, y) or Decimal.equals?(x, y) end def x <= y do Decimal.lt?(x, y) or Decimal.equals?(x, y) end def x > y do Decimal.gt?(x, y) end def x < y do Decimal.lt?(x, y) end
Sorry, something went wrong.
Although on the other hand it does match the javascript version:
No branches or pull requests
Currently this uses floats to perform arithmetic, which leads to unexpected evals over certain numerical intersections
This test currently passes, but most people's general conceptions would expect this to fail
The text was updated successfully, but these errors were encountered: