docs.intersystems.com
InterSystems IRIS Data Platform 2019.2  /  InterSystems SQL Reference

InterSystems SQL Reference
MOD
Previous section           Next section
InterSystems: The power behind what matters   
Search:  


A scalar numeric function that returns the modulus (remainder) of a number divided by another.
Synopsis
MOD(dividend,divisor)

{fn MOD(dividend,divisor)}
Arguments
dividend A number that is the numerator (dividend) of the division.
divisor A number that is the denominator (divisor) of the division.
MOD returns the NUMERIC data type unless the dividend is data type DOUBLE. If dividend is DOUBLE, MOD returns DOUBLE.
Description
MOD returns the mathematical remainder (modulus) from the dividend by the divisor.
MOD can be specified as either a standard scalar function or an ODBC scalar function with curly brace syntax.
The precision reported for MOD (either syntax form) is the same as the precision report for the arithmetic expression dividend/divisor.
ANSI Operator Precedence
The behavior of the MOD function with a single negative operand depends on the Apply ANSI Operator Precedence configuration setting:
The behavior of the # modulo operator is not affected by the Apply ANSI Operator Precedence configuration setting.
Examples
The following example shows the remainder returned by MOD.
SELECT MOD(5,3) AS Remainder
returns 2.
SELECT MOD(5.3,.5) AS Remainder
returns .3.
See Also
CEILING, FLOOR, ROUND, TRUNCATE


Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-08-23 05:52:04