Addition

Addition is a mathematical operation that represents combining collections of objects together into a larger collection

Modulo

The modulo (sometimes called modulus) operation finds the remainder of division of one number by another

Higher precedence operator

Quality Example
Higher

"The modulo has a higher precedence than addition"

from question "Substitution encryption not returning characters"

More tightly

"Because the string formatting operator shares precedence with the remainder or modulo which binds more tightly than the + addition operator"

from question "%s formatting precedes + operator in joining two strings before formatting"

Higher operator

"The modulo has a higher operator precedence than the addition operator therefore it will happen before the addition"

from question "Trying to get a random number between two points and getting a divide by 0 error"

Higher precedence

"Multiplication division and modulo have the same precedence and they all have higher precedence than addition and subtraction"

from question "C basic code: Table of Precedence/Associativity"

"And keep in mind that the modulo has a higher precedence than addition and subtraction"

from question "CS50 Vigenere cipher giving wrong output"

"Note parentheses are redundant as division and multiplication have the same priority and modulo has higher precedence over addition"

from question "TSQL remap big number to smaller, but keep Identity"

"Modulo can also cause a divide-by-zero and it has a higher precedence than addition"

from question "I am getting a Divide by zero error but can't figure out why"

Operations important slower

Quality Example
Much cheaper

"The addition is much cheaper than other operations like modulo and division and array access"

from question "Huge performance drop with increment by one"

Slower integer

"Integer multiplication division and modulo are much slower than integer addition and subtraction"

from question "Haskell style/efficiency"

Slower

"Then you can process any length number using very few division remainder modulo operations which is important because they are much slower than addition"

from question "Divide a large number represented in string by 3"

"Division and modulo are indeed costly hardware operations whatever you do this is more related to hardware architecture than to languages or compilers perhaps ten times slower than addition"

from question "Alternative to using % operator and / Operator in C++"

Others

Quality Example
Weaker

"Is the modulo really weaker than the addition"

from question "Java modulo operator precedence"

Better

"The result of the addition was better than the modulo the by 0.0070000 milliseconds over the course of 2 million or 200 000 iterations"

from question "What is the more efficient syntax to produce an even number in my console project?"

Back to Home
Data comes from Stack Exchange with CC-BY-SA-3.0