In computing and mathematics, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another, the latter being called the modulus of the operation.

Given two positive numbers a and n, a modulo n (often abbreviated as a mod n) is the remainder of the Euclidean division of a by n, where a is the dividend and n is the divisor.[1]

For example, the expression "5 mod 2" evaluates to 1, because 5 divided by 2 has a quotient of 2 and a remainder of 1, while "9 mod 3" would evaluate to 0, because 9 divided by 3 has a quotient of 3 and a remainder of 0.

Although typically performed with a and n both being integers, many computing systems now allow other types of numeric operands. The range of values for an integer modulo operation of n is 0 to n − 1. a mod 1 is always 0.

When exactly one of a or n is negative, the basic definition breaks down, and programming languages differ in how these values are defined.

Variants of the definition

In mathematics, the result of the modulo operation is an equivalence class, and any member of the class may be chosen as representative; however, the usual representative is the least positive residue, the smallest non-negative integer that belongs to that class (i.e., the remainder of the Euclidean division).[2] However, other conventions are possible. Computers and calculators have various ways of storing and representing numbers; thus their definition of the modulo operation depends on the programming language or the underlying hardware.

In nearly all computing systems, the quotient q and the remainder r of a divided by n \neq 0 satisfy the following conditions:

This still leaves a sign ambiguity if the remainder is non-zero: two possible choices for the remainder occur, one negative and the other positive; that choice determines which of the two consecutive quotients must be used to satisfy equation (1). In number theory, the positive remainder is always chosen, but in computing, programming languages choose depending on the language and the signs of a or n.[a] Standard Pascal and ALGOL 68, for example, give a positive remainder (or 0) even for negative divisors, and some programming languages, such as C90, leave it to the implementation when either of n or a is negative (see the table under § In programming languages for details). Some systems leave a modulo 0 undefined, though others define it as a.

Many implementations use truncated division, for which the quotient is defined by

q = \operatorname{trunc}\left(\frac{a}{n}\right)

where \operatorname{trunc} is the integral part function (rounding toward zero), i.e. the truncation to zero significant digits. Thus according to equation (), the remainder has the same sign as the dividend a so can take 2|n| − 1 values:

r = a - n \operatorname{trunc}\left(\frac{a}{n}\right)

Donald Knuth[3] promotes floored division, for which the quotient is defined by

q = \left\lfloor\frac{a}{n}\right\rfloor

where \lfloor\,\rfloor is the floor function (rounding down). Thus according to equation (), the remainder has the same sign as the divisor n:

r = a - n \left\lfloor\frac{a}{n}\right\rfloor

Raymond T. Boute[4] promotes Euclidean division, for which the non-negative remainder r \in \{0, 1, 2...\} is defined by

r := a - nq \ \mathrm{such\ that} \ {\color{red}{0 \leq r}} < |n|.

(Emphasis added.) Under this definition, we can say the following about the quotient q:

\begin{align}
q &= \frac{a - r}{n} \in \mathbb{Z} \\
&= \text{sgn}(n) \cdot \frac{a-r}{|n|} \\
&= \text{sgn}(n) \cdot \left( \frac{a}{|n|} - \frac{r}{|n|} \right) \\
&= \text{sgn}(n) \cdot \left\lfloor \frac{a}{\left|n\right|} \right\rfloor
\end{align}

where sgn is the sign function, \lfloor\,\rfloor is the floor function (rounding down), and \frac{a}{|n|} \in \mathbb{Q}, \frac{r}{|n|} \in \mathbb{Q} are rational numbers.

Equivalently, one may instead define the quotient q \in \mathbb{Z} as follows:

q := \sgn(n) \left\lfloor\frac{a}{\left|n\right|}\right\rfloor =
\begin{cases}
  \left\lfloor\frac{a}{n}\right\rfloor & \text{if } n > 0 \\
  \left\lceil\frac{a}{n}\right\rceil   & \text{if } n < 0 \\
\end{cases}

where \lceil\,\rceil is the ceiling function (rounding up). Thus according to equation (), the remainder r is non-negative:

r = a - nq = a - |n| \left\lfloor\frac{a}{\left|n\right|}\right\rfloor

Common Lisp and IEEE 754 use rounded division, for which the quotient is defined by

q = \operatorname{round}\left(\frac{a}{n}\right)

where round is the round function (rounding half to even). Thus according to equation (), the remainder falls between -\frac{n}{2} and \frac{n}{2}, and its sign depends on which side of zero it falls to be within these boundaries:

r = a - n \operatorname{round}\left(\frac{a}{n}\right)

Common Lisp also uses ceiling division, for which the quotient is defined by

q = \left\lceil\frac{a}{n}\right\rceil

where ⌈⌉ is the ceiling function (rounding up). Thus according to equation (), the remainder has the opposite sign of that of the divisor:

r = a - n \left\lceil\frac{a}{n}\right\rceil

If both the dividend and divisor are positive, then the truncated, floored, and Euclidean definitions agree. If the dividend is positive and the divisor is negative, then the truncated and Euclidean definitions agree. If the dividend is negative and the divisor is positive, then the floored and Euclidean definitions agree. If both the dividend and divisor are negative, then the truncated and floored definitions agree.

However, truncated division satisfies the identity ({-a})/b = {-(a/b)} = a/({-b}).[5][6]

Notation

Some calculators have a mod() function button, and many programming languages have a similar function, expressed as mod(a, n), for example. Some also support expressions that use "%", "mod", or "Mod" as a modulo or remainder operator, such as a % n or a mod n.

For environments lacking a similar function, any of the three definitions above can be used.

Common pitfalls

When the result of a modulo operation has the sign of the dividend (truncated definition), it can lead to surprising mistakes.

For example, to test if an integer is odd, one might be inclined to test if the remainder by 2 is equal to 1:

bool is_odd(int n) {
    return n % 2 == 1;
}

But in a language where modulo has the sign of the dividend, that is incorrect, because when n (the dividend) is negative and odd, n mod 2 returns −1, and the function returns false.

One correct alternative is to test that the remainder is not 0 (because remainder 0 is the same regardless of the signs):

bool is_odd(int n) {
    return n % 2 != 0;
}

Or with the binary arithmetic:

bool is_odd(int n) {
    return n & 1;
}

Performance issues

Modulo operations might be implemented such that a division with a remainder is calculated each time. For special cases, on some hardware, faster alternatives exist. For example, the modulo of powers of 2 can alternatively be expressed as a bitwise AND operation (assuming x is a positive integer, or using a non-truncating definition):

x % 2n == x & (2n - 1)

Examples:

x % 2 == x & 1
x % 4 == x & 3
x % 8 == x & 7

In devices and software that implement bitwise operations more efficiently than modulo, these alternative forms can result in faster calculations.[7]

Compiler optimizations may recognize expressions of the form expression % constant where constant is a power of two and automatically implement them as expression & (constant-1), allowing the programmer to write clearer code without compromising performance. This simple optimization is not possible for languages in which the result of the modulo operation has the sign of the dividend (including C), unless the dividend is of an unsigned integer type. This is because, if the dividend is negative, the modulo will be negative, whereas expression & (constant-1) will always be positive. For these languages, the equivalence x % 2n == x < 0 ? x | ~(2n - 1) : x & (2n - 1) has to be used instead, expressed using bitwise OR, NOT and AND operations.

Optimizations for general constant-modulus operations also exist by calculating the division first using the constant-divisor optimization.

Properties (identities)

Some modulo operations can be factored or expanded similarly to other mathematical operations. This may be useful in cryptography proofs, such as the Diffie–Hellman key exchange. The properties involving multiplication, division, and exponentiation generally require that a and n are integers.

  • Identity:
  • Inverse:
  • Distributive:
    • (a + b) mod n = [(a mod n) + (b mod n)] mod n.
    • ab mod n = [(a mod n)(b mod n)] mod n.
  • Division (definition): ab mod n = [(a mod n)(b−1 mod n)] mod n, when the right hand side is defined (that is when b and n are coprime), and undefined otherwise.
  • Inverse multiplication: [(ab mod n)(b−1 mod n)] mod n = a mod n.

In programming languages

Modulo operators in various programming languages
LanguageOperatorIntegerFloating-pointDefinition
ABAPMODEuclidean[8]
ActionScript%Truncated[9]
AdamodFloored[10]
remTruncated[10]
ALGOL 68÷×, ÷*, , %*, mod[b]Euclidean[11]
AMPLmodTruncated
APL|[c]Floored
AppleScriptmodTruncated
AutoLISPremTruncated
AWK%Truncated (same as fmod in C)[12]
BASICModVaries by implementation
bc%Truncated[13]
C
C++
%, divTruncated[d]
fmod (C)
std::fmod (C++)
Truncated[14]
remainder (C)
std::remainder (C++)
Rounded[15]
C#%Truncated[16]
Math.IEEERemainderRounded[17]
Clarion%Truncated
CleanremTruncated
ClojuremodFloored[18]
remTruncated[19]
COBOLFUNCTION MODFloored[20]
FUNCTION REMTruncated[20]
CoffeeScript%Truncated
%%Floored[21]
ColdFusion%, MODTruncated
Common Intermediate Languagerem (signed)Truncated[22]
rem.un (unsigned)
Common LispmodFloored[23]
remTruncated[23]
Crystal%, moduloFloored
remainderTruncated
CSSmod()Floored[24]
rem()Truncated[25]
D%Truncated[26]
Dart%Euclidean[27]
remainder()Truncated[28]
dc%Truncated[29]
Eiffel\\Truncated
Elixirrem/2Truncated[30]
Integer.mod/2Floored[31]
ElmmodByFloored[32]
remainderByTruncated[33]
ErlangremTruncated
math:fmod/2Truncated (same as C)[34]
EuphoriaremainderTruncated[35]
modFloored[36]
F#%Truncated (same as C#)[37]
Math.IEEERemainderRounded[17]
FactormodTruncated[38]
remEuclidean[39]
FileMakerModFloored
ForthmodImplementation defined
fm/modFloored
sm/remTruncated
FortranmodTruncated[40]
moduloFloored[41]
FrinkmodFloored
Full BASICMODFloored[42]
REMAINDERTruncated[43]
GLSL%Undefined[44]
modFloored[45]
GameMaker Studio (GML)mod, %Truncated
GDScript (Godot)%Truncated[46]
posmodEuclidean[47]
fmodTruncated[48]
fposmodEuclidean[49]
Go%Truncated[50]
math.ModTruncated[51]
big.Int.ModEuclidean[52]
big.Int.RemTruncated[53]
Groovy%Truncated
HaskellmodFloored[54]
remTruncated[54]
Data.Fixed.mod' (GHC)Floored
Haxe%Truncated[55]
HLSL%Undefined[56]
J|[c]Floored
Java%Truncated[57]
Integer.remainderUnsigned, Long.remainderUnsigned[58][59]
Math.ceilMod, StrictMath.ceilModCeiling[60][61][62][63][64][65]
Math.floorMod, StrictMath.floorModFloored[66][67][68][69][70][71]
Math.IEEEremainder, StrictMath.IEEEremainderRounded[72][73]
a.mod(b) (BigInteger)Euclidean[74]
a.remainder(b) (BigInteger)Truncated[75]
a.remainder(b), a.remainder(b, mathContext) (BigDecimal)Truncated[76][77]
JavaScript
TypeScript
%Truncated
JuliamodFloored[78]
%, remTruncated[79]
Kotlin%, remTruncated[80]
modFloored[81]
ksh%Truncated (same as POSIX sh)
fmodTruncated
LabVIEWmodTruncated
LibreOfficeMODFloored[82]
LogoMODULOFloored
REMAINDERTruncated
Lua 5%Floored
Lua 4mod(x,y)Truncated
Liberty BASICMODTruncated
Mathcadmod(x,y)Floored
Maplee mod m (by default), modp(e, m)Euclidean
mods(e, m)Rounded
frem(e, m)Rounded
MathematicaMod[a, b]Floored[83]
MATLABmodFloored[84]
remTruncated[85]
MaximamodFloored
remainderTruncated
Maya Embedded Language%Truncated
Microsoft ExcelMODFloored[86]
MinitabMODFloored
Modula-2MODFloored
REMTruncated
MUMPS#Floored
Netwide Assembler (NASM, NASMX)%, div (unsigned)
%% (signed)Implementation-defined[87]
NimmodTruncated
OberonMODFloored-like[e]
Objective-C%Truncated (same as C99)
Object Pascal, DelphimodTruncated
OCamlmodTruncated[88]
mod_floatTruncated[89]
Occam\Truncated
Pascal (ISO-7185 and -10206)modEuclidean-like[f]
Perl%Floored[g]
POSIX::fmodTruncated (same as C)[90]
PHP%Truncated[91]
fmodTruncated[92]
PIC BASIC Pro\\Truncated
PL/ImodFloored (ANSI PL/I)
PowerShell%Truncated
Programming Code (PRC)MATH.OP - 'MOD; (\)'Undefined
ProgressmoduloTruncated
PrologmodFloored
remTruncated
PureBasic%, Mod(x,y)Truncated
PureScript`mod`Euclidean[93]
Pure Data%Truncated (same as C)
modFloored
Python%Floored[94]
math.fmodTruncated[95]
math.remainderRounded[96]
Q#%Truncated[97]
R%%Floored[98]
RacketmoduloFloored
remainderTruncated
Raku%Floored
RealBasicMODTruncated
ReasonmodTruncated
Rexx//Truncated
RPG%REMTruncated
Ruby%, modulo()Floored
remainder()Truncated
Rust%Truncated[99]
rem_euclid()Euclidean[100]
SASMODTruncated
Scala%Truncated
SchememoduloFloored
remainderTruncated
Scheme R6RSmodEuclidean[101]
mod0Rounded[101]
flmodEuclidean
flmod0Rounded
ScratchmodFloored
Seed7modFloored
remTruncated
SenseTalkmoduloFloored
remTruncated
sh (POSIX) (includes bash, mksh, &c.)%Truncated (same as C)[102]
Smalltalk\\Floored[103]: sec. 5.6.2.9
rem:Truncated[103]: sec. 5.6.2.30
Snap!modFloored
Spin//Floored
Solidity%Truncated[104]
SQL ()mod(x,y)Truncated
SQL ()%Truncated
Standard MLmodFloored
Int.remTruncated
Real.remTruncated
Statamod(x,y)Euclidean
Swift%Truncated[105]
remainder(dividingBy:)Rounded[106]
truncatingRemainder(dividingBy:)Truncated[107]
Tclexpr a % n, ::tcl::mathop::% a n[h]Floored[108][109]
expr fmod(a, n), ::tcl::mathfunc::fmod a n[i]Truncated (same as C)
tcsh%Truncated
Torque%Truncated
TuringmodFloored
Verilog (2001)%Truncated
VHDLmodFloored
remTruncated
VimL%Truncated
Visual BasicModTruncated
WebAssemblyi32.rem_u, i64.rem_u (unsigned)[110]
i32.rem_s, i64.rem_s (signed)Truncated[110]
x86 assemblyDIV (unsigned)
IDIV (signed)Truncated
FPREMTruncated
FPREM1Rounded
XBase++%Truncated
Mod()Floored
Zig%, @remTruncated[111]
@modFloored
Z3 theorem proverdiv, modEuclidean

In addition, many computer systems provide a divmod functionality, which produces the quotient and the remainder at the same time. Examples include the x86 architecture's DIV and IDIV instructions, the C programming language's div() function, and Python's divmod() function.

Generalizations

Modulo with offset

Sometimes it is useful for the result of a modulo n to lie not between 0 and n − 1, but between some number d and d + n − 1. In that case, d is called an offset and d = 1 is particularly common.

There does not seem to be a standard notation for this operation, so let us tentatively use a modd n. We thus have the following definition:[112] x = a modd n just in case dxd + n − 1 and x mod n = a mod n. Clearly, the usual modulo operation corresponds to zero offset: a mod n = a mod0 n.

The operation of modulo with offset is related to the floor function as follows:

a \operatorname{mod}_d n = a - n \left\lfloor\frac{a-d}{n}\right\rfloor.

To see this, let x = a - n \left\lfloor\frac{a-d}{n}\right\rfloor. We first show that x mod n = a mod n. It is in general true that (a + bn) mod n = a mod n for all integers b; thus, this is true also in the particular case when b = -\!\left\lfloor\frac{a-d}{n}\right\rfloor; but that means that x \bmod n = \left(a - n \left\lfloor\frac{a-d}{n}\right\rfloor\right)\! \bmod n = a \bmod n, which is what we wanted to prove. It remains to be shown that dxd + n − 1. Let k and r be the integers such that ad = kn + r with 0 ≤ rn − 1 (see Euclidean division). Then \left\lfloor\frac{a-d}{n}\right\rfloor = k, thus x = a - n \left\lfloor\frac{a-d}{n}\right\rfloor = a - n k = d +r. Now take 0 ≤ rn − 1 and add d to both sides, obtaining dd + rd + n − 1. But we've seen that x = d + r, so we are done.

The modulo with offset a modd n is implemented in Mathematica as Mod[a, n, d] .[112]

Implementing other modulo definitions using truncation

Despite the mathematical elegance of Knuth's floored division and Euclidean division, it is generally much more common to find a truncated division-based modulo in programming languages. Leijen provides the following algorithms for calculating the two divisions given a truncated integer division:

/* Euclidean and Floored divmod, in the style of C's ldiv() */
typedef struct {
  /* This structure is part of the C stdlib.h, but is reproduced here for clarity */
  long int quot;
  long int rem;
} ldiv_t;

/* Euclidean division */
inline ldiv_t ldivE(long numer, long denom) {
  /* The C99 and C++11 languages define both of these as truncating. */
  long q = numer / denom;
  long r = numer % denom;
  if (r < 0) {
    if (denom > 0) {
      q = q - 1;
      r = r + denom;
    } else {
      q = q + 1;
      r = r - denom;
    }
  }
  return (ldiv_t){.quot = q, .rem = r};
}

/* Floored division */
inline ldiv_t ldivF(long numer, long denom) {
  long q = numer / denom;
  long r = numer % denom;
  if ((r > 0 && denom < 0) || (r < 0 && denom > 0)) {
    q = q - 1;
    r = r + denom;
  }
  return (ldiv_t){.quot = q, .rem = r};
}

For both cases, the remainder can be calculated independently of the quotient, but not vice versa. The operations are combined here to save screen space, as the logical branches are the same.

See also

Notes

  1. ^ Mathematically, these two choices are but two of the infinite number of choices available for the inequality satisfied by a remainder.
  2. ^ The revised report uses boldface to distinguish between keywords and identifiers, but permits other formats, including capitalization (e.g. MOD).
  3. ^ Argument order reverses, i.e., α|ω computes \omega\bmod\alpha, the remainder when dividing ω by α.
  4. ^ C99 and C++11 define the behavior of % to be truncated.[113] The standards before then leave the behavior implementation-defined.[114]
  5. ^ Divisor must be positive, otherwise undefined.
  6. ^ As discussed by Boute, ISO Pascal's definitions of div and mod do not obey the Division Identity of D = d · (D / d) + D % d, and are thus fundamentally broken.
  7. ^ Perl usually uses arithmetic modulo operator that is machine-independent. For examples and exceptions, see the Perl documentation on multiplicative operators.[115]
  8. ^ The expr command is defined independantly of commands in the ::tcl::mathop namespace.[116]
  9. ^ The expr command is defined in terms of commands in the ::tcl::mathfunc namespace.[117]

References

  1. ^ Weisstein, Eric W. "Congruence". Wolfram MathWorld. Retrieved 2020-08-27.
  2. ^ Caldwell, Chris. "residue". Prime Glossary. Retrieved August 27, 2020.
  3. ^ Knuth, Donald. E. (1972). The Art of Computer Programming. Addison-Wesley.
  4. ^ Boute, Raymond T. (April 1992). "The Euclidean definition of the functions div and mod". ACM Transactions on Programming Languages and Systems. 14 (2): 127–144. ACM Press (New York, NY, USA). doi:10.1145/128861.128862. hdl:1854/LU-314490. S2CID 8321674
  5. ^ Peterson, Doctor (5 July 2001). "Mod Function and Negative Numbers". Math Forum - Ask Dr. Math. Archived 2019-10-22 at the Wayback Machine. Retrieved 22 October 2019.
  6. ^ "Ada 83 LRM, Sec 4.5: Operators and Expression Evaluation". archive.adaic.com. Retrieved 2025-03-03.
  7. ^ Horvath, Adam (July 5, 2012). "Faster division and modulo operation - the power of two"
  8. ^ "ABAP Keyword Documentation". help.sap.com. 2024. Retrieved 2026-01-18.
  9. ^ "Operators - Adobe ActionScript® 3 (AS3) API Reference". help.adobe.com. Retrieved 2026-01-19.
  10. ^ ISO/IEC 8652:2012 - Information technology — Programming languages — Ada. ISO, IEC. 2012. sec. 4.5.5 Multiplying Operators.
  11. ^ Revised Report on the Algorithmic Language Algol 68. IFIP WG2.1. 1973. sec. 10.2.3.3.n.
  12. ^ "awk". pubs.opengroup.org. Retrieved 2026-01-19.
  13. ^ "bc". pubs.opengroup.org. Retrieved 2026-05-23.
  14. ^ ISO/IEC 9899:1990: Programming languages – C. ISO, IEC. 1990. sec. 7.5.6.4. The fmod function returns the value x - i * y, for some integer i such that, if y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y.
  15. ^ ISO/IEC 9899:1999: Programming languages — C. ISO, IEC. 1999. sec. 7.12.10.2. The remainder functions compute the remainder x REM y required by IEC 60559.
  16. ^ "Expressions - C# language specification". learn.microsoft.com. Retrieved 2026-01-19.
  17. ^ dotnet-bot. "Math.IEEERemainder(Double, Double) Method (System)". Microsoft Learn. Retrieved 2022-10-04.
  18. ^ "clojure.core - Clojure v1.10.3 API documentation". clojure.github.io. Retrieved 2022-03-16.
  19. ^ "clojure.core - Clojure v1.10.3 API documentation". clojure.github.io. Retrieved 2022-03-16.
  20. ^ ((ISO/IEC JTC 1/SC 22/WG 4)) (January 2023). ISO/IEC 1989:2023 – Programming language COBOL. ISO
  21. ^ CoffeeScript operators
  22. ^ ((ISO/IEC JTC 1/SC 22)) (February 2012). ISO/IEC 23271:2012 — Information technology — Common Language Infrastructure (CLI). ISO. §§ III.3.55–56.
  23. ^ "CLHS: Function MOD, REM". www.lispworks.com. Retrieved 2026-01-20.
  24. ^ "mod() - CSS: Cascading Style Sheets | MDN". developer.mozilla.org. 2024-06-22. Retrieved 2024-10-23.
  25. ^ "rem() - CSS: Cascading Style Sheets | MDN". developer.mozilla.org. 2024-10-15. Retrieved 2024-10-23.
  26. ^ "Expressions - D Programming Language". dlang.org. Retrieved 2021-06-01.
  27. ^ "operator % method - num class - dart:core library - Dart API". api.dart.dev. Retrieved 2021-06-01.
  28. ^ "remainder method - num class - dart:core library - Dart API". api.dart.dev. Retrieved 2021-06-01.
  29. ^ "dc, an arbitrary precision calculator". www.gnu.org. Archived 2025-12-10 at the Wayback Machine. Retrieved 2026-05-23.
  30. ^ "Kernel — Elixir v1.11.3". hexdocs.pm. Retrieved 2021-01-28.
  31. ^ "Integer — Elixir v1.11.3". hexdocs.pm. Retrieved 2021-01-28.
  32. ^ "Basics - core 1.0.5". package.elm-lang.org. Retrieved 2022-03-16.
  33. ^ "Basics - core 1.0.5". package.elm-lang.org. Retrieved 2022-03-16.
  34. ^ "Erlang -- math". erlang.org. Retrieved 2021-06-01.
  35. ^ "OpenEuphoria: Euphoria v4.0". openeuphoria.org. Retrieved 2026-01-20.
  36. ^ "OpenEuphoria: Euphoria v4.0". openeuphoria.org. Retrieved 2026-01-20.
  37. ^ "18. The F# Library FSharp.Core.dll - F# Language Specification". fsharp.github.io. Retrieved 2026-01-19.
  38. ^ "mod ( x y -- z ) - Factor Documentation". docs.factorcode.org. Retrieved 2026-01-21.
  39. ^ "rem ( x y -- z ) - Factor Documentation". docs.factorcode.org. Retrieved 2026-01-21.
  40. ^ "Manipulation and properties of numeric values — Fortran Programming Language". fortran-lang.org. Retrieved 2026-05-22.
  41. ^ "Manipulation and properties of numeric values — Fortran Programming Language". fortran-lang.org. Retrieved 2026-05-22.
  42. ^ ANSI (28 January 1987). Programming Languages — Full BASIC. New York: American National Standards Institute. § 5.4.4. X modulo Y, i.e., X-Y*INT(X/Y).
  43. ^ ANSI (28 January 1987). Programming Languages — Full BASIC. New York: American National Standards Institute. § 5.4.4. "The remainder function, i.e., X-Y*IP(X/Y)."
  44. ^ "GLSL Language Specification, Version 4.50.7". section 5.9 Expressions. If both operands are non-negative, then the remainder is non-negative. Results are undefined if one or both operands are negative.
  45. ^ "GLSL Language Specification, Version 4.50.7". section 8.3 Common Functions.
  46. ^ "int". Godot Engine documentation. Retrieved 2026-01-19.
  47. ^ "@GlobalScope". Godot Engine documentation. Retrieved 2026-01-19.
  48. ^ "@GlobalScope". Godot Engine documentation. Retrieved 2026-01-19.
  49. ^ "@GlobalScope". Godot Engine documentation. Retrieved 2026-01-19.
  50. ^ "The Go Programming Language Specification - The Go Programming Language". go.dev. Retrieved 2022-02-28.
  51. ^ "math package - math - pkg.go.dev". pkg.go.dev. Retrieved 2022-02-28.
  52. ^ "big package - math/big - pkg.go.dev". pkg.go.dev. Retrieved 2022-02-28.
  53. ^ "big package - math/big - pkg.go.dev". pkg.go.dev. Retrieved 2024-04-12.
  54. ^ "6 Predefined Types and Classes". www.haskell.org. Retrieved 2022-05-22.
  55. ^ "Binary Operators". Haxe - The Cross-platform Toolkit. Retrieved 2026-01-20.
  56. ^ "Operators". Microsoft. 30 June 2021. Retrieved 2021-07-19. The % operator is defined only in cases where either both sides are positive or both sides are negative. Unlike C, it also operates on floating-point data types, as well as integers.
  57. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-24.
  58. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  59. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  60. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  61. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  62. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  63. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  64. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  65. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  66. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  67. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  68. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  69. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  70. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  71. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  72. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  73. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  74. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  75. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  76. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  77. ^ "Java Platform, Standard Edition Java API Reference". docs.oracle.com. Retrieved 2026-05-25.
  78. ^ "Mathematics · The Julia Language". docs.julialang.org. Retrieved 2021-11-20.
  79. ^ "Mathematics · The Julia Language". docs.julialang.org. Retrieved 2021-11-20.
  80. ^ "rem - Kotlin Programming Language". Kotlin. Retrieved 2021-05-05.
  81. ^ "mod - Kotlin Programming Language". Kotlin. Retrieved 2021-05-05.
  82. ^ "Mathematical Functions". help.libreoffice.org. Retrieved 2026-01-21.
  83. ^ "Mod: Get the remainder on division—Wolfram Documentation". reference.wolfram.com. Retrieved 2026-05-25.
  84. ^ "mod - Remainder after division (modulo operation) - MATLAB". www.mathworks.com. Archived 2026-01-15 at the Wayback Machine. Retrieved 2026-01-21.
  85. ^ "rem - Remainder after division - MATLAB". www.mathworks.com. Archived 2026-01-01 at the Wayback Machine. Retrieved 2026-01-21.
  86. ^ "MOD function - Microsoft Support". support.microsoft.com. Retrieved 2026-01-21.
  87. ^ "Chapter 3: The NASM Language". NASM - The Netwide Assembler version 2.15.05
  88. ^ "OCaml library : Stdlib". ocaml.org. Retrieved 2022-02-19.
  89. ^ "OCaml library : Stdlib". ocaml.org. Retrieved 2022-02-19.
  90. ^ "POSIX - Perl interface to IEEE Std 1003.1 - Perldoc Browser". perldoc.perl.org. Retrieved 2026-05-22.
  91. ^ "PHP: Arithmetic Operators - Manual". www.php.net. Retrieved 2021-11-20.
  92. ^ "PHP: fmod - Manual". www.php.net. Retrieved 2021-11-20.
  93. ^ "EuclideanRing"
  94. ^ "6. Expressions". Python documentation. Retrieved 2026-01-21.
  95. ^ "math — Mathematical functions". Python documentation. Retrieved 2026-01-21.
  96. ^ "math — Mathematical functions". Python documentation. Retrieved 2026-01-21.
  97. ^ QuantumWriter. "Expressions". docs.microsoft.com. Retrieved 2018-07-11.
  98. ^ "R: Arithmetic Operators". search.r-project.org. Retrieved 2022-12-24.
  99. ^ "Operator expressions - The Rust Reference". doc.rust-lang.org. Retrieved 2026-01-21.
  100. ^ "F32 - Rust"
  101. ^ r6rs.org
  102. ^ "Shell Command Language". pubs.opengroup.org. Retrieved 2021-02-05.
  103. ^ ANSI INCITS 319-1998 (R2002): Information Technology - Programming Languages - Smalltalk. American National Standards Institute (ANSI). 1998.
  104. ^ "Solidity Documentation". docs.soliditylang.org. Retrieved 2024-10-17.
  105. ^ "Apple Developer Documentation". developer.apple.com. Retrieved 2021-11-20.
  106. ^ "Apple Developer Documentation". developer.apple.com. Retrieved 2021-11-20.
  107. ^ "Apple Developer Documentation". developer.apple.com. Retrieved 2021-11-20.
  108. ^ "expr manual page - Tcl Built-In Commands". www.tcl-lang.org. Retrieved 2026-05-22.
  109. ^ "mathop manual page - Tcl Mathematical Operator Commands". www.tcl-lang.org. Retrieved 2026-05-22.
  110. ^ Rossberg, Andreas (ed.) (19 April 2022). "WebAssembly Core Specification: Version 2.0". World Wide Web Consortium. § 4.3.2 Integer Operations.
  111. ^ "Zig Documentation". Zig Programming Language. Retrieved 2022-12-18.
  112. ^ "Mod". Wolfram Language & System Documentation Center. Wolfram Research. 2020. Retrieved April 8, 2020.
  113. ^ "C99 specification (ISO/IEC 9899:TC2)". 2005-05-06. sec. 6.5.5 Multiplicative operators. Retrieved 16 August 2018.
  114. ^ ISO/IEC 14882:2003: Programming languages – C++. International Organization for Standardization (ISO), International Electrotechnical Commission (IEC). 2003. sec. 5.6.4. the binary % operator yields the remainder from the division of the first expression by the second. .... If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined
  115. ^ Perl documentation
  116. ^ "mathop manual page - Tcl Mathematical Operator Commands". www.tcl-lang.org. Retrieved 2026-05-22.
  117. ^ "mathfunc manual page - Tcl Mathematical Functions". www.tcl-lang.org. Retrieved 2026-05-22.