Skip to content
New issue

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

Koan about rounding pitfalls #268

Open
Goutte opened this issue Oct 17, 2021 · 1 comment
Open

Koan about rounding pitfalls #268

Goutte opened this issue Oct 17, 2021 · 1 comment

Comments

@Goutte
Copy link

Goutte commented Oct 17, 2021

I love these koans !

Is it relevant to drop a word of caution regarding rounding?

  koan "But beware of floating dragons" do
    assert Float.round(2.675, 2) == ___
  end
@iamvery
Copy link
Collaborator

iamvery commented Jul 14, 2024

Sure! Open a PR 😎

Goutte added a commit to Goutte/elixir-koans that referenced this issue Jul 15, 2024
The solution is 2.67

This is because 2.675 is actually approximated in IEE754:
2.67499999999999982236431605997495353221893310546875

Close, but no cigar.

Fixes elixirkoans#268

/spend 30m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants