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
-- Function call
f1 := MODULO(10, 3)
;Result
| f1 BIGINT |
|---|
| 1 |
.MODULO(...) — chained
FeatureQL
SELECT
-- Integer literal: parenthesize for `.MODULO` on BIGINT
f1 := (10).MODULO(3),
-- Decimal base: chain without extra parentheses
f2 := 10.0.MODULO(3)
;Result
| f1 BIGINT | f2 VARCHAR |
|---|---|
| 1 | 1.0 |
Edge cases
FeatureQL
SELECT
-- Another remainder
f1 := MODULO(15, 4),
-- No remainder
f2 := MODULO(7, 7),
-- Negative dividend
f3 := MODULO(-10, 3)
;Result
| f1 BIGINT | f2 BIGINT | f3 BIGINT |
|---|---|---|
| 3 | 0 | -1 |