MODULO()
All functions > MATH > MODULO()
Returns the remainder after dividing the first number by the second.
Signatures
Modulo
Returns: Remainder of the division
MODULO(dividend: T, divisor: T) → T sql
| Parameter | Type | Required | Description |
|---|---|---|---|
dividend | T | Yes | Number to be divided |
divisor | T | Yes | Number to divide by |
With:
T: Custom types: TINYINT | SMALLINT | INT | BIGINT | DECIMAL
Signature notes:
- Both arguments must be of the same type (integer or DECIMAL)
- Sign of the result matches the sign of the dividend
- Returns NULL if either operand is NULL
- Division by zero raises an error
Aliases
MOD
Related operators
Examples
MODULO(...)
FeatureQL
SELECT
f1 := MODULO(10, 3) -- Function call
;Result
| f1 BIGINT |
|---|
| 1 |
.MODULO(...) — chained
FeatureQL
SELECT
f1 := (10).MODULO(3), -- Integer literal: parenthesize for `.MODULO` on BIGINT
f2 := 10.0.MODULO(3) -- Decimal base: chain without extra parentheses
;Result
| f1 BIGINT | f2 VARCHAR |
|---|---|
| 1 | 1.0 |
Edge cases
FeatureQL
SELECT
f1 := MODULO(15, 4), -- Another remainder
f2 := MODULO(7, 7), -- No remainder
f3 := MODULO(-10, 3) -- Negative dividend
;Result
| f1 BIGINT | f2 BIGINT | f3 BIGINT |
|---|---|---|
| 3 | 0 | -1 |