Skip to content

Rename modulo to remainder and add examples #4630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cousteaulecommandant opened this issue Mar 1, 2016 · 2 comments
Closed

Rename modulo to remainder and add examples #4630

cousteaulecommandant opened this issue Mar 1, 2016 · 2 comments
Labels
Component: Documentation Related to Arduino's documentation content

Comments

@cousteaulecommandant
Copy link
Contributor

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.

@TheAustrian
Copy link

I agree - especially since in the example it's promoted as a way to stay within the bounds of an array. Woe to those who try to count down instead of up in such an instance.

@per1234 per1234 added the Component: Documentation Related to Arduino's documentation content label Jul 4, 2017
@per1234
Copy link
Collaborator

per1234 commented Apr 18, 2018

Resolved by: arduino/reference-en#350

@per1234 per1234 closed this as completed Apr 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation Related to Arduino's documentation content
Projects
None yet
Development

No branches or pull requests

3 participants