json-logic-php
json-logic-php copied to clipboard
Is modulo intended to be for use with integers only, or floats?
trafficstars
I'm happy to submit a PR, but I ran across an instance where running {"%": [10.5, 2]} resulted in 1 instead of 0.5. I checked against the JavaScript implementation and noticed that it returns floats as expected.
In PHP the % operator is called the "integer modulus," and the function for floating point calculations is called fmod(). (See: https://www.php.net/manual/en/function.fmod.php).
I'll code up the PR real quick, just wanted to detail the scenario, because I understand that making a change like would be considered a breaking change to anyone who, for whatever reason, is expecting only int values from a floating point modulus operation.