Skip to content

Is modulo intended to be for use with integers only, or floats? #8

@CoeusCC

Description

@CoeusCC

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions