Modulo in order of operation

Adam Harte picture Adam Harte · Jun 24, 2010 · Viewed 54.1k times · Source

Where does modulo come in the mathematical order of operation? I am guessing it is similar to division, but before or after?

Answer

walkytalky picture walkytalky · Jun 24, 2010

This depends on the language, but in C style languages % is the same precedence as * and /. This means that if it appears in the same expression (without parentheses) the order depends on the associativity. In this case % is usually left-associative, so the operators will be executed in left-to-right order.