Skip to content

Rename modulo to remainder and add examples #4630

Closed
@cousteaulecommandant

Description

@cousteaulecommandant

First, the Arduino reference refers to % as "modulo". However "remainder" is a more appropriate (and familiar) name (and the one used in the C++ standard to describe what % does; also it's the third word that appears in the description in the Arduino documentation).
Second, the reference should include some examples of what happens when you % negative numbers. Here's where the conceptual difference between "remainder" and "modulo" lies: the result of the former has the same sign as the FIRST operand, whereas the latter would have the one of the SECOND. This is annoying since almost in 100% of the cases where % meets negatives you want the second behavior (e.g. (-13) % 10 yielding 7); however C++ surprises you with the first behavior (-3). Therefore it is important to clarify this in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions