json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

multipleOf not working as expected

Open nikcani opened this issue 2 years ago • 4 comments

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 :)

nikcani avatar Nov 03 '22 08:11 nikcani

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

cc @Flynamic

MathieM avatar Jan 06 '23 13:01 MathieM

Dealing with float is not easy in PHP.

sure, thx for trying

nikcani avatar Jan 06 '23 14:01 nikcani

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

MathieM avatar Jan 06 '23 17:01 MathieM

Thanks for improving :)

nikcani avatar Jan 07 '23 18:01 nikcani