Skip to content

Precedence of % (mod) is higher than * and / #3301

Closed
@gwhitney

Description

@gwhitney

The issues section is used only for bug reports. Please use the Discussions section to ask questions and share ideas and suggestions.

Describe the bug
Unlike in any other language I have checked, the precedence of % (or mod) used as a binary remainder operator is higher than * and /. As it is essentially a division operation, its precedence should be the same as * and /, as it is in essentially every other language checked.

To Reproduce
Evaluate 3.6 * 28 % 25. Currently mathjs produces 10.8 = 3.6 * 3 = 3.6 * (28 % 25). It should produce 0.8 = 100.8 % 25 = (3.6 * 28) % 25, as multiplicative/division operators should be evaluated left to right.

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