Integer Operations
There are four supported integer datatypes, TINYINT
(8 bits),
SMALLINT
(16 bits), INTEGER
(32 bits), and BIGINT
(64
bits).
The legal operations are +
(plus, unary and binary), -
(minus,
unary and binary), *
(multiplication), /
(division), %
(modulus).
Modulus involving negative numbers happens as follows:
For: mod = x % y
- if
x >= 0
andy > 0
then:x - (floor(x / y) * y)
- if
x >= 0
andy < 0
then:x % abs(y)
- if
x < 0
andy > 0
then:- abs(x) % y
- if
x < 0
andy > 0
then:- abs(x) % abs(y)
Example:
x | y | mod |
---|---|---|
8 | 3 | 2 |
8 | -3 | 2 |
-8 | 3 | -2 |
-8 | -3 | -2 |
Casting a string to an integer type will produce a runtime error if the string cannot be interpreted as a number.
Division or modulus by zero cause a runtime error.
Operations that cause integer overflow or underflow (example: multiplication or division of minimum integer value by -1) produce run time errors.
Predefined functions on integer values
Function | Description |
---|---|
ABS(value) | return absolute value. |
MOD(left, right) | integer modulus. Same as left % right . |
SEQUENCE(start, end) | returns an array of integers from start to end (inclusive). If end < start, an empty array is returned. If any of the arguments are NULL, NULL is returned. |
Operations not supported
Non-deterministic functions, such as RAND
are currently not
supported in DBSP.