Top "Modulo" questions

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

C and Python - different behaviour of the modulo (%) operation

I have found that the same mod operation produces different results depending on what language is being used. In Python: …

python c math modulo
Why is 0 mod 0 an error?

If I type: int main() { return 0 % 0; } I get back an error: error C2124: divide or mod by zero What is …

c++ visual-c++ math modulo divide-by-zero
Maximum subarray sum modulo M

Most of us are familiar with the maximum sum subarray problem. I came across a variant of this problem which …

algorithm binary-search modulo kadanes-algorithm
Fastest way to calculate a 128-bit integer modulo a 64-bit integer

I have a 128-bit unsigned integer A and a 64-bit unsigned integer B. What's the fastest way to calculate A % …

c algorithm x86 modulo assembly
Is there an expression using modulo to do backwards wrap-around ("reverse overflow")?

For any whole number input W restricted by the range R = [x,y], the "overflow," for lack of a better …

c++ modulo algebra
Modulus/Remainder function for non-integers

rem gives this: Prelude> rem 9 8 1 I wanted something like this: Prelude> nonIntRem 9.1 8 1.0999999999999996 I implemented it like this: nonIntRem …

haskell floating-point modulo
Why is modulus operator slow?

Paraphrasing from in "Programming Pearls" book (about c language on older machines, since book is from the late 90's): Integer …

modulo integer-division cpu-speed programming-pearls
How to calculate "modular multiplicative inverse" when the denominator is not co-prime with m?

I need to calculate (a/b) mod m where a and b are very large numbers. What I am trying …

numbers modulo largenumber
How can I do mod without a mod operator?

This scripting language doesn't have a % or Mod(). I do have a Fix() that chops off the decimal part of …

modulo roku brightscript
Modulus division when first number is smaller than second number

I apologize if this is a simple question but I'm having trouble grasping the concept of modulus division when the …

java modulo integer-division arithmetic-expressions