You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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
yielding7
); however C++ surprises you with the first behavior (-3
). Therefore it is important to clarify this in the documentation.The text was updated successfully, but these errors were encountered: