Arithmetic#
CEL supports standard arithmetic operations on numeric types.
Negation#
The unary - operator negates a numeric value.
Negation is not defined for unsigned integers.
Basic operations#
Addition, subtraction, multiplication, and division work on numeric types.
Integer division truncates toward zero.
Modulo#
The % operator returns the remainder after division.
The result has the same sign as the dividend.
Operator precedence#
Multiplication, division, and modulo have higher precedence than addition and subtraction.
Division by zero#
Integer and unsigned integer division by zero produces a runtime error.
Double division by zero produces special values.
Overflow#
Integer operations that exceed the 64-bit range produce a runtime error.
Unsigned integer overflow also produces a runtime error.
Mixed types#
Numeric types cannot be mixed directly.
Convert explicitly into matching types.
See also#
- Booleans and numbers - Numeric types
- Time - Timestamp and duration arithmetic