The Global Conference for Wikimedia 6 - 10 August 2014 · - TopicsExpress



          

The Global Conference for Wikimedia 6 - 10 August 2014 · London Find out more Close Modulo operation From Wikipedia, the free encyclopedia (Redirected from Modulo operator) Quotient (red) and remainder (green) functions using different algorithms In computing, the modulo (sometimes called modulus) operation finds the remainder of division of one number by another. Given two positive numbers, a (the dividend) and n (the divisor), a modulo n (abbreviated as a mod n) is the remainder of the Euclidean division of a by n. For instance, the expression 5 mod 2 would evaluate to 1 because 5 divided by 2 leaves a quotient of 2 and a remainder of 1, while 9 mod 3 would evaluate to 0 because the division of 9 by 3 has a quotient of 3 and leaves a remainder of 0; there is nothing to subtract from 9 after multiplying 3 times 3. (Note that doing the division with a calculator wont show the result referred to here by this operation; the quotient will be expressed as a decimal fraction.) Although typically performed with a and n both being integers, many computing systems allow other types of numeric operands. The range of numbers for an integer modulo of n is 0 to n − 1. (n mod 1 is always 0; n mod 0 is undefined, possibly resulting in a Division by zero error in computer programming languages) See modular arithmetic for an older and related convention applied in number theory. When either a or n is negative, the naive definition breaks down and programming languages differ in how these values are defined. Contents 1 Remainder calculation for the modulo operation 2 Common pitfalls 3 Modulo operation expression 4 Performance issues 5 Equivalencies 6 See also 7 Notes 8 References Remainder calculation for the modulo operation Integer modulo operators in various programming languages Language Operator Result has the same sign as ActionScript % Dividend Ada mod Divisor rem Dividend ASP Mod Not defined ALGOL-68 ÷×, mod Always positive AMPL mod Dividend APL | Divisor AppleScript mod Dividend AWK % Dividend BASIC Mod Not defined bash % Dividend bc % Dividend C (ISO 1990) % Implementation defined C (ISO 1999) % Dividend[1] C++ (ISO 1998) % Implementation defined[2] C++ (ISO 2011) % Dividend C# % Dividend CLARION % Dividend Clojure mod Divisor COBOL[1] FUNCTION MOD Divisor ColdFusion %, MOD Dividend Common Lisp mod Divisor rem Dividend D % Dividend[3] Dart % Always Positive remainder() Dividend Eiffel \\ Dividend Erlang rem Dividend Euphoria mod Divisor remainder Dividend F# % Dividend FileMaker Mod Divisor Forth mod implementation defined Fortran mod Dividend modulo Divisor Frink mod Divisor GML (Game Maker) mod Dividend GDScript mod Dividend Go % Dividend Haskell mod Divisor rem Dividend Haxe % Dividend J |~ Divisor Java % Dividend JavaScript % Dividend Julia mod Divisor rem Dividend Lua 5 % Divisor Lua 4 mod(x,y) Divisor Liberty BASIC MOD Dividend MathCad mod(x,y) Divisor Maple e mod m Always positive Mathematica Mod Divisor MATLAB mod Divisor rem Dividend Maxima mod Divisor remainder Dividend Maya Embedded Language % Dividend Microsoft Excel =MOD() Divisor Minitab MOD Divisor mksh % Dividend Modula-2 MOD Divisor[2] MUMPS # Divisor NASM NASMX % Unsigned Modulo Operator %% Signed Modulo Operator Oberon MOD Divisor[3] OCaml mod Dividend Occam \ Dividend Pascal (Delphi) mod Dividend Pascal (ISO-7185 and ISO-10206) mod Always positive Perl % Divisor[4] PHP % Dividend PIC Basic Pro \\ Dividend PL/I mod Divisor (ANSI PL/I) PowerBuilder mod(x,y) ? PowerShell % Dividend Progress modulo Dividend Prolog (ISO 1995) mod Divisor rem Dividend Python % Divisor Racket remainder Dividend RealBasic MOD Dividend R %% Divisor REXX // Dividend RPG %REM Dividend Ruby %, modulo() Divisor remainder() Dividend Scala % Dividend Scheme modulo Divisor remainder Dividend Scheme R6RS mod Always positive[4] mod0 Closest to zero[4] Seed7 mod Divisor rem Dividend SenseTalk modulo Divisor rem Dividend Smalltalk \\ Divisor rem: Dividend SQL (SQL:1999) mod(x,y) Dividend Standard ML mod Divisor Int.rem Dividend Stata mod(x,y) Always positive Swift % Dividend Tcl % Divisor Torque Game Engine % Dividend Turing mod Divisor Verilog (2001) % Dividend VHDL mod Divisor rem Dividend Visual Basic Mod Dividend x86 Assembly IDIV Dividend Xbase++ % Dividend Mod() Divisor Floating-point modulo operators in various programming languages Language Operator Result has the same sign as C (ISO 1990) fmod ? C (ISO 1999) fmod Dividend remainder Closest to zero C++ (ISO 1998) std::fmod ? C++ (ISO 2011) std::fmod Dividend std::remainder Closest to zero C# % Dividend Common Lisp mod Divisor rem Dividend D % Dividend Dart % Always Positive remainder() Dividend F# % Dividend Fortran mod Dividend modulo Divisor Go math.Fmod Dividend Haskell (GHC) Data.Fixed.mod Divisor Java % Dividend JavaScript % Dividend Microsoft Excel =MOD() Divisor OCaml mod_float Dividend Perl POSIX::fmod Dividend Perl6 % Divisor PHP fmod Dividend Python % Divisor math.fmod Dividend REXX // Dividend Ruby %, modulo() Divisor remainder() Dividend Scheme R6RS flmod Always positive flmod0 Closest to zero Standard ML Real.rem Dividend Swift % Dividend Xbase++ % Dividend Mod()
Posted on: Sat, 05 Jul 2014 02:29:16 +0000

Trending Topics



Recently Viewed Topics




© 2015