Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Modulo
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==In programming languages== {{sticky header}} {| class="wikitable sortable sticky-header" |+ Modulo operators in various programming languages |- ! scope="col" | [[Programming language|Language]] ! scope="col" | Operator ! scope="col" | Integer ! scope="col" | Floating-point ! abbr="Sign" scope="col" | [[#Variants of the definition|Definition]] |- | [[ABAP]] | {{code|MOD}} | {{yes}} | {{yes}} | Euclidean |- | [[ActionScript]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[Ada (programming language)|Ada]] | {{code|mod}} | {{yes}} | {{no}} | Floored<ref name="Ada">{{Cite book|title=ISO/IEC 8652:2012 - Information technology β Programming languages β Ada|publisher=[[International Organization for Standardization|ISO]], [[International Electrotechnical Commission|IEC]]|year=2012|at=sec. 4.5.5 Multiplying Operators}}</ref> |- | {{code|rem}} | {{yes}} | {{no}} | Truncated<ref name="Ada" /> |- | [[ALGOL 68]] | {{code|Γ·Γ}}, {{code|mod}} | {{yes}} | {{no}} | Euclidean |- | [[AMPL]] | {{code|mod}} | {{yes}} | {{no}} | Truncated |- | [[APL (programming language)|APL]] | <code><nowiki>|</nowiki></code>{{efn|name=rev|Argument order reverses, i.e., <code><nowiki>Ξ±|Ο</nowiki></code> computes <math>\omega\bmod\alpha</math>, the remainder when dividing {{code|Ο}} by {{code|Ξ±}}.}} | {{yes}} | {{yes}} | Floored |- | [[AppleScript]] | {{code|mod}} | {{yes}} | {{no}} | Truncated |- | [[AutoLISP]] | {{code|(rem d n)}} | {{yes}} | {{no}} | Truncated |- | [[AWK]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | [[bash (Unix shell)|bash]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | [[BASIC]] | {{code|Mod}} | {{yes}} | {{no}} | Varies by implementation |- | [[bc (programming language)|bc]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | rowspan="3" | [[C (programming language)|C]]{{break}}[[C++]] | {{code|%}}, {{code|div}} | {{yes}} | {{no}} | Truncated{{efn|name=c|[[C99]] and [[C++11]] define the behavior of {{code|%}} to be truncated.<ref name="C99">{{cite web |title=C99 specification (ISO/IEC 9899:TC2) |url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf |access-date=16 August 2018 |at=sec. 6.5.5 Multiplicative operators |date=2005-05-06}}</ref> The standards before then leave the behavior implementation-defined.<ref>{{Cite book|year=2003|title=ISO/IEC 14882:2003: Programming languages β C++|publisher=[[International Organization for Standardization]] (ISO), [[International Electrotechnical Commission]] (IEC)|at=sec. 5.6.4|quote=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}}</ref>}} |- | {{code|fmod}} (C){{break}}{{code|std::fmod}} (C++) | {{no}} | {{yes}} | Truncated<ref>{{Cite book|title=ISO/IEC 9899:1990: Programming languages β C |publisher=[[International Organization for Standardization|ISO]], [[International Electrotechnical Commission|IEC]] |year=1990 |at=sec. 7.5.6.4 |quote=The {{math|fmod}} function returns the value {{math|x - i * y}}, for some integer {{math|i}} such that, if {{math|y}} is nonzero, the result has the same sign as {{math|x}} and magnitude less than the magnitude of {{math|y}}.}}</ref> |- | {{code|remainder}} (C){{break}}{{code|std::remainder}} (C++) | {{no}} | {{yes}} | Rounded |- | rowspan="2" | [[C Sharp (programming language)|C#]] | {{code|%}} | {{yes}} | {{yes}} | Truncated |- | {{code|Math.IEEERemainder}} | {{no}} | {{yes}} | Rounded<ref name=".NET">{{Cite web |last=dotnet-bot |title=Math.IEEERemainder(Double, Double) Method (System) |url=https://learn.microsoft.com/en-us/dotnet/api/system.math.ieeeremainder?view=net-7.0 |access-date=2022-10-04 |website=Microsoft Learn |language=en-us}}</ref> |- | [[Clarion (programming language)|Clarion]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | [[Clean (programming language)|Clean]] | {{code|rem}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[Clojure]] | {{code|mod}} | {{yes}} | {{no}} | Floored<ref>{{Cite web |title=clojure.core - Clojure v1.10.3 API documentation |url=https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/mod |access-date=2022-03-16 |website=clojure.github.io}}</ref> |- | {{code|rem}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web |title=clojure.core - Clojure v1.10.3 API documentation |url=https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/rem |access-date=2022-03-16 |website=clojure.github.io}}</ref> |- | rowspan="2" | [[COBOL]] | {{code|FUNCTION MOD}} | {{yes}} | {{no}} | Floored<ref name="isocobol">{{cite book|title=ISO/IEC 1989:2023 β Programming language COBOL|author=ISO/IEC JTC 1/SC 22/WG 4|publisher=[[ISO]]|date=January 2023|url=https://www.iso.org/standard/74527.html|url-access=subscription}}</ref> |- | {{code|FUNCTION REM}} | {{yes}} | {{yes}} | Truncated<ref name="isocobol"/> |- | rowspan="2" | [[CoffeeScript]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | {{code|%%}} | {{yes}} | {{no}} | Floored<ref name="CoffeeScript">[http://coffeescript.org/#operators CoffeeScript operators]</ref> |- | [[ColdFusion]] | {{code|%}}, {{code|MOD}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[Common Intermediate Language]] | {{code|rem}} (signed) | {{yes}} | {{yes}} | Truncated<ref>{{cite book|last=ISO/IEC JTC 1/SC 22|date=February 2012|title=ISO/IEC 23271:2012 β Information technology β Common Language Infrastructure (CLI)|url=https://www.iso.org/standard/58046.html|publisher=[[ISO]]|at=Β§Β§ III.3.55β56}}</ref> |- | {{code|rem.un}} (unsigned) | {{yes}} | {{no}} | {{N/A}} |- | rowspan="2" | [[Common Lisp]] | {{code|mod}} | {{yes}} | {{yes}} | Floored |- | {{code|rem}} | {{yes}} | {{yes}} | Truncated |- | rowspan="2" | [[Crystal (programming language)|Crystal]] | {{code|%}}, {{code|modulo}} | {{yes}} | {{yes}} | Floored |- | {{code|remainder}} | {{yes}} | {{yes}} | Truncated |- | rowspan="2"| [[CSS]] | {{code|mod()}} | {{yes}} | {{yes}} | Floored<ref>{{Cite web |date=2024-06-22 |title=mod() - CSS: Cascading Style Sheets {{!}} MDN |url=https://developer.mozilla.org/en-US/docs/Web/CSS/mod |access-date=2024-10-23 |website=developer.mozilla.org |language=en-US}}</ref> |- | {{code|rem()}} | {{yes}} | {{yes}} | Truncated<ref>{{Cite web |date=2024-10-15 |title=rem() - CSS: Cascading Style Sheets {{!}} MDN |url=https://developer.mozilla.org/en-US/docs/Web/CSS/rem |access-date=2024-10-23 |website=developer.mozilla.org |language=en-US}}</ref> |- | [[D (programming language)|D]] | {{code|%}} | {{yes}} | {{yes}} | Truncated<ref>{{Cite web|title=Expressions - D Programming Language|url=https://dlang.org/spec/expression.html#mul_expressions|access-date=2021-06-01|website=dlang.org}}</ref> |- | rowspan="2" | [[Dart (programming language)|Dart]] | {{code|%}} | {{yes}} | {{yes}} | Euclidean<ref>{{Cite web|title=operator % method - num class - dart:core library - Dart API|url=https://api.dart.dev/stable/2.13.1/dart-core/num/operator_modulo.html|access-date=2021-06-01|website=api.dart.dev}}</ref> |- | {{code|remainder()}} | {{yes}} | {{yes}} | Truncated<ref>{{Cite web|title=remainder method - num class - dart:core library - Dart API|url=https://api.dart.dev/stable/2.13.1/dart-core/num/remainder.html|access-date=2021-06-01|website=api.dart.dev}}</ref> |- | [[Eiffel (programming language)|Eiffel]] | {{code|\\}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[Elixir (programming language)|Elixir]] | {{code|rem/2}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web|title=Kernel β Elixir v1.11.3|url=https://hexdocs.pm/elixir/Kernel.html#rem/2|access-date=2021-01-28|website=hexdocs.pm}}</ref> |- | {{code|Integer.mod/2}} | {{yes}} | {{no}} | Floored<ref>{{Cite web|title=Integer β Elixir v1.11.3|url=https://hexdocs.pm/elixir/Integer.html#mod/2|access-date=2021-01-28|website=hexdocs.pm}}</ref> |- | rowspan="2" | [[Elm (programming language)|Elm]] | {{code|modBy}} | {{yes}} | {{no}} | Floored<ref>{{Cite web |title=Basics - core 1.0.5 |url=https://package.elm-lang.org/packages/elm/core/latest/Basics#modBy |access-date=2022-03-16 |website=package.elm-lang.org}}</ref> |- | {{code|remainderBy}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web |title=Basics - core 1.0.5 |url=https://package.elm-lang.org/packages/elm/core/latest/Basics#remainderBy |access-date=2022-03-16 |website=package.elm-lang.org}}</ref> |- | rowspan="2" | [[Erlang (programming language)|Erlang]] | {{code|rem}} | {{yes}} | {{no}} | Truncated |- | {{code|math:fmod/2}} | {{no}} | {{yes}} | Truncated (same as C)<ref>{{Cite web|title=Erlang -- math|url=https://erlang.org/doc/man/math.html#fmod-2|access-date=2021-06-01|website=erlang.org}}</ref> |- | rowspan="2" | [[Euphoria (programming language)|Euphoria]] | {{code|mod}} | {{yes}} | {{no}} | Floored |- | {{code|remainder}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[F Sharp (programming language)|F#]] | {{code|%}} | {{yes}} | {{yes}} | Truncated |- | {{code|Math.IEEERemainder}} | {{no}} | {{yes}} | Rounded<ref name=".NET" /> |- | [[Factor (programming language)|Factor]] | {{code|mod}} | {{yes}} | {{no}} | Truncated |- | [[FileMaker]] | {{code|Mod}} | {{yes}} | {{no}} | Floored |- | rowspan="3" | [[Forth (programming language)|Forth]] | {{code|mod}} | {{yes}} | {{no}} | Implementation defined |- | {{code|fm/mod}} | {{yes}} | {{no}} | Floored |- | {{code|sm/rem}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[Fortran]] | {{code|mod}} | {{yes}} | {{yes}} | Truncated |- | {{code|modulo}} | {{yes}} | {{yes}} | Floored |- | [[Frink (programming language)|Frink]] | {{code|mod}} | {{yes}} | {{no}} | Floored |- | rowspan="2" | [[Full BASIC]] | {{code|MOD}} | {{yes}} | {{yes}} | Floored<ref>{{cite book|last=[[ANSI]]|title=Programming Languages β Full BASIC|url=https://archive.org/details/federalinformat6821nati_0|date=28 January 1987|publisher=American National Standards Institute|location=New York|at=Β§ 5.4.4|quote=X modulo Y, i.e., X-Y*INT(X/Y).}}</ref> |- | {{code|REMAINDER}} | {{yes}} | {{yes}} | Truncated<ref>{{cite book|last=[[ANSI]]|title=Programming Languages β Full BASIC|url=https://archive.org/details/federalinformat6821nati_0|date=28 January 1987|publisher=American National Standards Institute|location=New York|at=Β§ 5.4.4|quote="The remainder function, i.e., X-Y*IP(X/Y)."}}</ref> |- | rowspan="2" | [[GLSL]] | {{code|%}} | {{yes}} | {{no}} | Undefined<ref>{{cite web|url=https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.50.pdf|title=GLSL Language Specification, Version 4.50.7|at=section 5.9 Expressions|quote=If both operands are non-negative, then the remainder is non-negative. Results are undefined if one or both operands are negative.}}</ref> |- | {{code|mod}} | {{no}} | {{yes}} | Floored<ref>{{cite web|url=https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.50.pdf|title=GLSL Language Specification, Version 4.50.7|at=section 8.3 Common Functions}}</ref> |- | [[GameMaker Studio]] (GML) | {{code|mod}}, {{code|%}} | {{yes}} | {{no}} | Truncated |- | rowspan="4" | [[Godot (game engine)|GDScript (Godot)]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | {{code|fmod}} | {{no}} | {{yes}} | Truncated |- | {{code|posmod}} | {{yes}} | {{no}} | Euclidean |- | {{code|fposmod}} | {{no}} | {{yes}} | Euclidean |- | rowspan="4" | [[Go (programming language)|Go]] | {{code|%}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web |title=The Go Programming Language Specification - The Go Programming Language |url=https://go.dev/ref/spec#Integer_operators |access-date=2022-02-28 |website=go.dev}}</ref> |- | {{code|math.Mod}} | {{no}} | {{yes}} | Truncated<ref>{{Cite web |title=math package - math - pkg.go.dev |url=https://pkg.go.dev/math#Mod |access-date=2022-02-28 |website=pkg.go.dev}}</ref> |- | {{code|big.Int.Mod}} | {{yes}} | {{no}} | Euclidean<ref>{{Cite web |title=big package - math/big - pkg.go.dev |url=https://pkg.go.dev/math/big#Int.Mod |access-date=2022-02-28 |website=pkg.go.dev}}</ref> |- | {{code|big.Int.Rem}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web |title=big package - math/big - pkg.go.dev |url=https://pkg.go.dev/math/big#Int.Rem |access-date=2024-04-12 |website=pkg.go.dev}}</ref> |- | [[Apache Groovy|Groovy]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | rowspan="3" | [[Haskell (programming language)|Haskell]] | {{code|mod}} | {{yes}} | {{no}} | Floored<ref name="Haskell 2010">{{Cite web |title=6 Predefined Types and Classes |url=https://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1370006.4.2 |access-date=2022-05-22 |website=www.haskell.org}}</ref> |- | {{code|rem}} | {{yes}} | {{no}} | Truncated<ref name="Haskell 2010" /> |- | {{code|Data.Fixed.mod'}} ([[Glasgow Haskell Compiler|GHC]]) | {{no}} | {{yes}} | Floored |- | [[Haxe]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | [[HLSL]] | {{code|%}} | {{yes}} | {{yes}} | Undefined<ref>{{cite web |url=https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-operators#additive-and-multiplicative-operators |title=Operators |author=<!--Not stated--> |date=30 June 2021 |publisher=[[Microsoft]] |access-date=2021-07-19 |quote=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.}}</ref> |- | [[J (programming language)|J]] | <code><nowiki>|</nowiki></code>{{efn|name=rev}} | {{yes}} | {{no}} | Floored |- | rowspan="2" | [[Java (programming language)|Java]] | {{code|%}} | {{yes}} | {{yes}} | Truncated |- | {{code|Math.floorMod}} | {{yes}} | {{no}} | Floored |- | [[JavaScript]]{{break}}[[TypeScript]] | {{code|%}} | {{yes}} | {{yes}} | Truncated |- | rowspan="2" | [[Julia (programming language)|Julia]] | {{code|mod}} | {{yes}} | {{yes}} | Floored<ref>{{Cite web|title=Mathematics Β· The Julia Language|url=https://docs.julialang.org/en/v1/base/math/#Base.mod|access-date=2021-11-20|website=docs.julialang.org}}</ref> |- | {{code|%}}, {{code|rem}} | {{yes}} | {{yes}} | Truncated<ref>{{Cite web|title=Mathematics Β· The Julia Language|url=https://docs.julialang.org/en/v1/base/math/#Base.rem|access-date=2021-11-20|website=docs.julialang.org}}</ref> |- | rowspan="2" | [[Kotlin (programming language)|Kotlin]] | {{code|%}}, {{code|rem}} | {{yes}} | {{yes}} | Truncated<ref>{{Cite web|title=rem - Kotlin Programming Language|url=https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/rem.html|access-date=2021-05-05|website=Kotlin|language=en}}</ref> |- | {{code|mod}} | {{yes}} | {{yes}} | Floored<ref>{{Cite web|title=mod - Kotlin Programming Language|url=https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/mod.html|access-date=2021-05-05|website=Kotlin|language=en}}</ref> |- | rowspan="2" | [[KornShell|ksh]] | {{code|%}} | {{yes}} | {{no}} | Truncated (same as POSIX sh) |- | {{code|fmod}} | {{no}} | {{yes}} | Truncated |- | [[LabVIEW]] | {{code|mod}} | {{yes}} | {{yes}} | Truncated |- | [[LibreOffice]] | {{code|1==MOD()}} | {{yes}} | {{no}} | Floored |- | rowspan="2" | [[Logo (programming language)|Logo]] | {{code|MODULO}} | {{yes}} | {{no}} | Floored |- | {{code|REMAINDER}} | {{yes}} | {{no}} | Truncated |- | [[Lua (programming language)|Lua]] 5 | {{code|%}} | {{yes}} | {{yes}} | Floored |- | [[Lua (programming language)|Lua]] 4 | {{code|mod(x,y)}} | {{yes}} | {{yes}} | Truncated |- | [[Liberty BASIC]] | {{code|MOD}} | {{yes}} | {{no}} | Truncated |- | [[Mathcad]] | {{code|mod(x,y)}} | {{yes}} | {{no}} | Floored |- | rowspan="3" | [[Maple (software)|Maple]] | {{code|e mod m}} (by default), {{code|modp(e, m)}} | {{yes}} | {{no}} | Euclidean |- | {{code|mods(e, m)}} | {{yes}} | {{no}} | Rounded |- | {{code|frem(e, m)}} | {{yes}} | {{yes}} | Rounded |- | [[Mathematica]] | {{code|Mod[a, b]}} | {{yes}} | {{no}} | Floored |- | rowspan="2" | [[MATLAB]] | {{code|mod}} | {{yes}} | {{yes}} | Floored |- | {{code|rem}} | {{yes}} | {{yes}} | Truncated |- | rowspan="2" | [[Maxima (software)|Maxima]] | {{code|mod}} | {{yes}} | {{no}} | Floored |- | {{code|remainder}} | {{yes}} | {{no}} | Truncated |- | [[Maya Embedded Language]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | [[Microsoft Excel]] | {{code|1==MOD()}} | {{yes}} | {{yes}} | Floored |- | [[Minitab]] | {{code|MOD}} | {{yes}} | {{no}} | Floored |- | rowspan="2" | [[Modula-2]] | {{code|MOD}} | {{yes}} | {{no}} | Floored |- | {{code|REM}} | {{yes}} | {{no}} | Truncated |- | [[MUMPS]] | {{code|#}} | {{yes}} | {{no}} | Floored |- | rowspan="2" | [[Netwide Assembler]] ([[Netwide Assembler|NASM]], [[Netwide Assembler|NASMX]]) | {{code|%}}, {{code|div}} (unsigned) | {{yes}} | {{no}} | {{N/A}} |- | {{code|%%}} (signed) | {{yes}} | {{no}} | Implementation-defined<ref>{{cite web |title=Chapter 3: The NASM Language |url=https://nasm.us/doc/nasmdoc3.html#section-3.5.11 |website=NASM - The Netwide Assembler version 2.15.05}}</ref> |- | [[Nim (programming language)|Nim]] | {{code|mod}} | {{yes}} | {{no}} | Truncated |- | [[Oberon (programming language)|Oberon]] | {{code|MOD}} | {{yes}} | {{no}} | Floored-like{{efn|Divisor must be positive, otherwise undefined.}} |- | [[Objective-C]] | {{code|%}} | {{yes}} | {{no}} | Truncated (same as C99) |- | [[Object Pascal]], [[Delphi (programming language)|Delphi]] | {{code|mod}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[OCaml]] | {{code|mod}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web|title=OCaml library : Stdlib|url=https://ocaml.org/releases/4.13/api/Stdlib.html#VAL(mod)|access-date=2022-02-19|website=ocaml.org}}</ref> |- | {{code|mod_float}} | {{no}} | {{yes}} | Truncated<ref>{{Cite web|title=OCaml library : Stdlib|url=https://ocaml.org/releases/4.13/api/Stdlib.html#VALmod_float|access-date=2022-02-19|website=ocaml.org}}</ref> |- | [[Occam (programming language)|Occam]] | {{code|\}} | {{yes}} | {{no}} | Truncated |- | [[Pascal (programming language)|Pascal]] (ISO-7185 and -10206) | {{code|mod}} | {{yes}} | {{no}} | Euclidean-like{{efn|1=As discussed by Boute, ISO Pascal's definitions of {{code|div}} and {{code|mod}} do not obey the Division Identity of {{math|1=''D'' = ''d'' Β· (''D'' / ''d'') + ''D'' % ''d''}}, and are thus fundamentally broken.}} |- | rowspan="2" | [[Perl]] | {{code|%}} | {{yes}} | {{no}} | Floored{{efn|Perl usually uses arithmetic modulo operator that is machine-independent. For examples and exceptions, see the Perl documentation on multiplicative operators.<ref>[http://perldoc.perl.org/perlop.html#Multiplicative-Operators Perl documentation]</ref>}} |- | {{code|POSIX::fmod}} | {{no}} | {{yes}} | Truncated |- | rowspan="2" | [[Phix]] | {{code|mod}} | {{yes}} | {{no}} | Floored |- | {{code|remainder}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[PHP]] | {{code|%}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web|title=PHP: Arithmetic Operators - Manual|url=https://www.php.net/manual/en/language.operators.arithmetic.php|access-date=2021-11-20|website=www.php.net}}</ref> |- | {{code|fmod}} | {{no}} | {{yes}} | Truncated<ref>{{Cite web|title=PHP: fmod - Manual|url=https://www.php.net/manual/en/function.fmod.php|access-date=2021-11-20|website=www.php.net}}</ref> |- | PIC [[BASIC]] Pro | {{code|\\}} | {{yes}} | {{no}} | Truncated |- | [[PL/I]] | {{code|mod}} | {{yes}} | {{no}} | Floored (ANSI PL/I) |- | [[PowerShell]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | Programming Code ([[PRC (Palm OS)|PRC]]) | {{code|MATH.OP - 'MOD; (\)'}} | {{yes}} | {{no}} | Undefined |- | [[OpenEdge Advanced Business Language|Progress]] | {{code|modulo}} | {{yes}} | {{no}} | Truncated |- | rowspan="2"| [[Prolog]] ([https://www.iso.org/standard/21413.html ISO 1995]) | {{code|mod}} | {{yes}} | {{no}} | Floored |- | {{code|rem}} | {{yes}} | {{no}} | Truncated |- | [[PureBasic]] | {{code|%}}, {{code|Mod(x,y)}} | {{yes}} | {{no}} | Truncated |- | [[PureScript]] | {{code|`mod`}} | {{yes}} | {{no}} | Euclidean<ref name="purescript_euclid">{{Cite web|url=https://pursuit.purescript.org/packages/purescript-prelude/5.0.1/docs/Data.EuclideanRing#t:EuclideanRing|title = EuclideanRing}}</ref> |- | rowspan="2" | [[Pure Data]] | {{code|%}} | {{yes}} | {{no}} | Truncated (same as C) |- | {{code|mod}} | {{yes}} | {{no}} | Floored |- | rowspan="3" | [[Python (programming language)|Python]] | {{code|%}} | {{yes}} | {{yes}} | Floored |- | {{code|math.fmod}} | {{no}} | {{yes}} | Truncated |- | {{code|math.remainder}} | {{no}} | {{yes}} | Rounded |- | [[Q Sharp|Q#]] | {{code|%}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web|url=https://docs.microsoft.com/en-us/quantum/quantum-qr-expressions?view=qsharp-preview#numeric-expressions|title=Expressions|last=QuantumWriter|website=docs.microsoft.com|language=en-us|access-date=2018-07-11}}</ref> |- | [[R (programming language)|R]] | {{code|%%}} | {{yes}} | {{yes}} | Floored<ref>{{Cite web |title=R: Arithmetic Operators |url=https://search.r-project.org/R/refmans/base/html/Arithmetic.html |access-date=2022-12-24 |website=search.r-project.org}}</ref> |- | rowspan="2" |[[Racket (programming language)|Racket]] | {{code|modulo}} | {{yes}} | {{no}} | Floored |- | {{code|remainder}} | {{yes}} | {{no}} | Truncated |- | [[Raku (programming language)|Raku]] | {{code|%}} | {{no}} | {{yes}} | Floored |- | [[RealBasic]] | {{code|MOD}} | {{yes}} | {{no}} | Truncated |- | [[Reason (programming language)|Reason]] | {{code|mod}} | {{yes}} | {{no}} | Truncated |- | [[Rexx]] | {{code|//}} | {{yes}} | {{yes}} | Truncated |- | [[RPG (programming language)|RPG]] | {{code|%REM}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[Ruby (programming language)|Ruby]] | {{code|%}}, {{code|modulo()}} | {{yes}} | {{yes}} | Floored |- | {{code|remainder()}} | {{yes}} | {{yes}} | Truncated |- | rowspan="2" | [[Rust (programming language)|Rust]] | {{code|%}} | {{yes}} | {{yes}} | Truncated |- | {{code|rem_euclid()}} | {{yes}} | {{yes}} | Euclidean<ref name="rust_rem_euclid">{{Cite web|url=https://doc.rust-lang.org/std/primitive.f32.html#method.rem_euclid|title = F32 - Rust}}</ref> |- | [[SAS language|SAS]] | {{code|MOD}} | {{yes}} | {{no}} | Truncated |- | [[Scala (programming language)|Scala]] | {{code|%}} | {{yes}} | {{yes}} | Truncated |- | rowspan="2" | [[Scheme (programming language)|Scheme]] | {{code|modulo}} | {{yes}} | {{no}} | Floored |- | {{code|remainder}} | {{yes}} | {{no}} | Truncated |- | rowspan="4" | [[Scheme (programming language)|Scheme]] [[Scheme (programming language)#R6RS|R<sup>6</sup>RS]] | {{code|mod}} | {{yes}} | {{no}} | Euclidean<ref name="r6rs">[http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_sec_11.7.3.1 r6rs.org]</ref> |- | {{code|mod0}} | {{yes}} | {{no}} | Rounded<ref name="r6rs"/> |- | {{code|flmod}} | {{no}} | {{yes}} | Euclidean |- | {{code|flmod0}} | {{no}} | {{yes}} | Rounded |- | [[Scratch (programming language)|Scratch]] | {{code|mod}} | {{yes}} | {{yes}} | Floored |- | rowspan="2" | [[Seed7]] | {{code|mod}} | {{yes}} | {{yes}} | Floored |- | {{code|rem}} | {{yes}} | {{yes}} | Truncated |- | rowspan="2" | [[SenseTalk]] | {{code|modulo}} | {{yes}} | {{no}} | Floored |- | {{code|rem}} | {{yes}} | {{no}} | Truncated |- | [[POSIX shell|{{Code|sh}} (POSIX)]] (includes [[Bash (Unix shell)|bash]], [[mksh]], &c.) | {{code|%}} | {{yes}} | {{no}} | Truncated (same as C)<ref>{{Cite web|title=Shell Command Language|url=https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04|access-date=2021-02-05|website=pubs.opengroup.org}}</ref> |- | rowspan="2" | [[Smalltalk]] | {{code|\\}} | {{yes}} | {{no}} | Floored |- | {{code|rem:}} | {{yes}} | {{no}} | Truncated |- | [[Snap! (programming language)|Snap!]] | {{code|mod}} | {{yes}} | {{no}} | Floored |- | [[Parallax Propeller#Built in Spin byte code interpreter|Spin]] | {{code|//}} | {{yes}} | {{no}} | Floored |- | [[Solidity]] | {{code|%}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web|title=Solidity Documentation|url=https://docs.soliditylang.org/en/v0.8.28/types.html|access-date=2024-10-17|website=docs.soliditylang.org}}</ref> |- | [[SQL]] ([[SQL:1999]]) | {{code|mod(x,y)}} | {{yes}} | {{no}} | Truncated |- | [[SQL]] ([[SQL:2011]]) | {{code|%}} | {{yes}} | {{no}} | Truncated |- | rowspan="3" | [[Standard ML]] | {{code|mod}} | {{yes}} | {{no}} | Floored |- | {{code|Int.rem}} | {{yes}} | {{no}} | Truncated |- | {{code|Real.rem}} | {{no}} | {{yes}} | Truncated |- | [[Stata]] | {{code|mod(x,y)}} | {{yes}} | {{no}} | Euclidean |- | rowspan="3" | [[Swift (programming language)|Swift]] | {{code|%}} | {{yes}} | {{no}} | Truncated<ref>{{Cite web|title=Apple Developer Documentation|url=https://developer.apple.com/documentation/swift/binaryinteger/2885003|access-date=2021-11-20|website=developer.apple.com}}</ref> |- | {{code|remainder(dividingBy:)}} | {{no}} | {{yes}} | Rounded<ref>{{Cite web|title=Apple Developer Documentation|url=https://developer.apple.com/documentation/swift/floatingpoint/3017981-remainder|access-date=2021-11-20|website=developer.apple.com}}</ref> |- | {{code|truncatingRemainder(dividingBy:)}} | {{no}} | {{yes}} | Truncated<ref>{{Cite web|title=Apple Developer Documentation|url=https://developer.apple.com/documentation/swift/floatingpoint/3017995-truncatingremainder|access-date=2021-11-20|website=developer.apple.com}}</ref> |- | rowspan="2" | [[Tcl]] | {{code|%}} | {{yes}} | {{no}} | Floored |- | {{code|fmod()}} | {{no}} | {{yes}} | Truncated (as C) |- | [[tcsh]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | [[Torque (game engine)|Torque]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | [[Turing (programming language)|Turing]] | {{code|mod}} | {{yes}} | {{no}} | Floored |- | [[Verilog]] (2001) | {{code|%}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[VHDL]] | {{code|mod}} | {{yes}} | {{no}} | Floored |- | {{code|rem}} | {{yes}} | {{no}} | Truncated |- | [[Vimscript|VimL]] | {{code|%}} | {{yes}} | {{no}} | Truncated |- | [[Visual Basic .NET|Visual Basic]] | {{code|Mod}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[WebAssembly]] | {{code|i32.rem_u}}, {{code|i64.rem_u}} (unsigned) | {{yes}} | {{no}} | {{N/A}}<ref name="wasmcs2">{{cite web|editor-first1=Andreas|editor-last1=Rossberg|date=19 April 2022|title=WebAssembly Core Specification: Version 2.0|url=https://www.w3.org/TR/wasm-core-2/|publisher=[[World Wide Web Consortium]]|at=Β§ 4.3.2 Integer Operations}}</ref> |- | {{code|i32.rem_s}}, {{code|i64.rem_s}} (signed) | {{yes}} | {{no}} | Truncated<ref name="wasmcs2" /> |- | [[x86 assembly language|x86 assembly]] | {{code|IDIV}} | {{yes}} | {{no}} | Truncated |- | rowspan="2" | [[XBase++]] | {{code|%}} | {{yes}} | {{yes}} | Truncated |- | {{code|Mod()}} | {{yes}} | {{yes}} | Floored |- | rowspan="2" | [[Zig (programming language)|Zig]] | {{code|%}}, {{code|@rem}} | {{yes}} | {{yes}} | Truncated<ref>{{Cite web |title=Zig Documentation |url=https://ziglang.org/documentation/0.10.0/#Table-of-Operators |access-date=2022-12-18 |website=Zig Programming Language}}</ref> |- | {{code|@mod}} | {{yes}} | {{yes}} | Floored |- | [[Z3 Theorem Prover|Z3 theorem prover]] | {{code|div}}, {{code|mod}} | {{yes}} | {{no}} | Euclidean |} In addition, many computer systems provide a {{code|divmod}} functionality, which produces the quotient and the remainder at the same time. Examples include the [[x86 architecture]]'s {{code|IDIV}} instruction, the C programming language's {{code|div()}} function, and [[Python (programming language)|Python]]'s {{code|divmod()}} function.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)