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

multipleOf not working as expected #123

Open
nikcani opened this issue Nov 3, 2022 · 4 comments
Open

multipleOf not working as expected #123

nikcani opened this issue Nov 3, 2022 · 4 comments

Comments

@nikcani
Copy link

nikcani commented Nov 3, 2022

If you try to validate if the number 400.01 is a multiple of 0.01, you get an error that is not expected.

I have bcmath installed and thus Helper::isMultipleOf is going that way in my setup. Logging shows me that 400.01 is internally handled as 400.00999999999999 and 0.01 is 0.01000000000000, therefore the comparison is between 0 and 0.00999999999999.

I am unsure how to fix this, otherwise, I would have opened a pull request.

Thx upfront for any help :)

@MathieM
Copy link

MathieM commented Jan 6, 2023

@nikcani I add one PR #126.
Dealing with float is not easy in PHP.
There's remain some issues.

cc @Flynamic

@nikcani
Copy link
Author

nikcani commented Jan 6, 2023

Dealing with float is not easy in PHP.

sure, thx for trying

@MathieM
Copy link

MathieM commented Jan 6, 2023

It's not just a try.
It's an improvement and I found others issues with float.
But it works better with my fix.

I test firstly if I didn't add any regression. And I can assure you there is no regression

@nikcani
Copy link
Author

nikcani commented Jan 7, 2023

Thanks for improving :)

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