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

floating point operations and test #307

Open
lcrmorin opened this issue Feb 10, 2023 · 1 comment
Open

floating point operations and test #307

lcrmorin opened this issue Feb 10, 2023 · 1 comment

Comments

@lcrmorin
Copy link

lcrmorin commented Feb 10, 2023

I met a nasty bug that will now wake me up at night... It concerns floating point operations and I feel like it is not really included in your list. Note that one could argue this problem is not python specific but it still caused some nasty bug and people might want to be aware of this. (This blog reminded me of the bug and helped me formulate it more clearly here). It boils down to:

1 2 == 3
True

(1 2)/10 == 3/10
True

1/10 2/10 == 3/10
False

.1 .2 == .3
False

And of course :

0.3 - 0.2 - 0.1 == 0
False

@koldakov
Copy link

That's not a bug, that's how floating point works

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