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

feat(isDivisbleBy): bug fix (probably) #1350

Closed

Conversation

mum-never-proud
Copy link
Contributor

unsure if this was intentional, i consider it as a valid bug

resolves #1349

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)

Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a can of worms has been opened, how will you explain these:

> 4.2 % 2
0.20000000000000018

The float-point territory is a complicated one, and I don't know why we even went with allowing floats for the dividend 🤔

If it were up to me, I'd strictly go for integers for both...

@profnandaa
Copy link
Member

/cc. @HonzaKirchner ^

@HonzaKirchner
Copy link

HonzaKirchner commented Jun 9, 2020

I hoped it could be solved by comparing to EPSILON... But even more strangely

> 4.2 % 0.2
0.19999999999999996

@mum-never-proud
Copy link
Contributor Author

mum-never-proud commented Jun 11, 2020

@profnandaa I totally forgot that, but I do wonder if that's the case how banks and other services work? That needs high precision

@tux-tn
Copy link
Member

tux-tn commented Jun 11, 2020

@mum-never-proud they use special decimal datatypes and libraries like decimal.js

@profnandaa
Copy link
Member

Closing since #1354 is also closed.

@profnandaa profnandaa closed this Jun 11, 2020
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

Successfully merging this pull request may close these issues.

isDivisibleBy fails if argument is not integer
4 participants