In mathematics, division (÷) is an arithmetic elementary operation.


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

Wise operations slow

Quality Example

"If you compute modulo a power of two using bitwise and is simpler and generally faster than performing division"

from question "Assembly Language - How to Do Modulo?"

Much faster

"Since bit wise operations can be done very fast and division operations are relatively slow this type of modulo is much faster than doing a division"

from question "Low level implementation of bitwise Mod"

Number bits harder

Quality Example
Better straight

"Modulo gives you a remainder which is why it s better than straight division in situations where you re number of elements can change"

from question "Using jQuery to delay loading of divs?"

Much harder

"Programmers like to use this property to speed up programs because it s easy to chop off some number of bits but performing a modulo is much harder it s about as hard as doing a division"

from question "The idea behind unsigned integer"


Quality Example

"A side effect of many division routines is the modulo - so in few cases should division actually be faster than modulo"

from question "Is there any alternative to using % (modulus) in C/C++?"


"Inverse modulo for 300 time take 1.422 seconde more than executing division sub and multiplication 10k time even the core of inverse modulo is build with same division and sub and multiplication functions and for this number it just do 150 time inside while help plz why"

from question "ECC inverse modulo strange time execution"

"Modulo is more mathematical if you like while the remainder in the c-family is consistent with the common integer division satisfying and this is adopted from old fortran"

from question "Is there a modulus (not remainder) function / operation?"

Higher priority

"Is the same as because division has higher priority than modulo"

from question "C#: the most efficient way to convert int[] into a string"

Really more

"Python respects this definition whereas in most other programming language the modulo is really more like a reaminder after division operator"

from question "Modulo for negative dividends in Python"


"Using an extra variable to avoid the costly division and the resulting time was 18.9s so significantly better than the modulo with a statically known constant"

from question "Speed up C program without using conditional compilation"


"So in simple terms this should give you a feel for why division and hence modulo is slower computers still have to do long division in the same stepwise fashion tha you did in grade school"

from question "Why is modulus operator slow?"

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