Skip to content

Booleans and numbers#

CEL has primitive types for boolean and numeric values.

Booleans#

The boolean type has two values: true and false.

true
// result: true (bool)
false
// result: false (bool)

Integers#

Integers are 64-bit signed values. Literals can use decimal or hexadecimal (0x) notation.

42
// result: 42 (int)
0xFF
// result: 255 (int)

Literals that exceed the 64-bit signed range cause a compile error.

9223372036854775808
// error: invalid int literal

Unsigned integers#

Unsigned integers are 64-bit and use the u suffix.

42u
// result: 42 (uint)
0xFFu
// result: 255 (uint)

Literals that exceed the 64-bit unsigned range cause a compile error.

18446744073709551616u
// error: invalid uint literal

Doubles#

Doubles are 64-bit IEEE 754 floating-point numbers.

3.14
// result: 3.14 (double)

Scientific notation is supported.

6.022e23
// result: 6.022e+23 (double)
1.6e-19
// result: 1.6e-19 (double)

There are no literals for special values, but they can be produced through division or parsed from strings.

1.0 / 0.0
// result: +Inf (double)
-1.0 / 0.0
// result: -Inf (double)
0.0 / 0.0
// result: NaN (double)
double("Infinity")
// result: +Inf (double)
double("-Infinity")
// result: -Inf (double)
double("NaN")
// result: NaN (double)

See also#