Math extension for CEL — mirrors ext.Math() from cel-go.
Provides numeric functions under the math.* namespace.
Usage
env = Celixir.Environment.new() |> Celixir.Ext.Math.register()
Celixir.eval!("math.sqrt(16.0)", env) # => 4.0
Celixir.eval!("math.ceil(1.2)", env) # => 2.0Functions
math.ceil(double)— ceilingmath.floor(double)— floormath.round(double)— round (ties away from zero)math.trunc(double)— truncate fractional partmath.abs(int|uint|double)— absolute valuemath.sign(int|uint|double)— -1, 0, or 1math.sqrt(int|uint|double)— square root (NaN for negative)math.isNaN(double)— true if NaNmath.isInf(double)— true if ±Infmath.isFinite(double)— true if neither NaN nor Infmath.bitAnd(int, int)/math.bitAnd(uint, uint)math.bitOr(int, int)/math.bitOr(uint, uint)math.bitXor(int, int)/math.bitXor(uint, uint)math.bitNot(int)/math.bitNot(uint)math.bitShiftLeft(int|uint, int)math.bitShiftRight(int|uint, int)math.greatest(arg, ...)/math.greatest(list)— variadic max (built-in only)math.least(arg, ...)/math.least(list)— variadic min (built-in only)
Summary
Functions
Registers math extension functions into the given environment.
Functions
Registers math extension functions into the given environment.
Note: math.greatest and math.least are variadic macros handled by the
built-in evaluator and do not need explicit registration.