Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO: 
NoSQL
Returns the remainder from dividing the left-hand operator by the right-hand operator. For more information, see modulus operators.
Syntax
IntMod(<int_expr_1>, <int_expr_2>)
Arguments
| Description | |
|---|---|
| int_expr_1 | An integer expression, which is used as the left-hand operand. | 
| int_expr_2 | An integer expression, which is used as the right-hand operand. | 
Return types
Returns a 64-bit integer.
Note
For more information, see __int64.
Examples
This example tests the function with various static values.
SELECT VALUE {
    mod: IntMod(12, 5),
    positiveResult: IntMod(12, -5),
    negativeResult: IntMod(-12, -5),
    resultZero: IntMod(15, 5),
    modZero: IntMod(12, 0),
    modDecimal: IntMod(12, 0.2)
}
[
  {
    "mod": 2,
    "positiveResult": 2,
    "negativeResult": -2,
    "resultZero": 0
  }
]
Remarks
- This function expects integers for both arguments and performs operations assuming the values are a 64-bit integer.
- If any of the arguments aren't an integer, the function returns undefined.
- Overflow behavior is similar to the implementation in C++ (wrap-around).
- Modulus operators have left-to-right associativity.