Skip to main content
penscript supports arithmetic, number formatting, and numeric comparisons. These operators are used in computed form fields, premium calculations, validation rules, and automation conditions.

Addition: :sum

Returns the sum of all numbers in a list.
Works with variables:
Also used for date arithmetic — see the Dates & time page for details.

Subtraction: :substract

Returns the sequential subtraction of all numbers in a list. The first value is the starting point, and each subsequent value is subtracted from it.
Works with variables:
Also supports date arithmetic — see the Dates & time page for details.

Multiplication: :product

Returns the product of all numbers in the input array.
Commonly used inside :pipe for sequential transformations:

Division: :divide

Divides the first number by the second.

Power: :power

Raises a base to an exponent.

Min / Max: :min, :max

Returns the lowest or highest value from an array.
Works with variables:

Fixed Decimals: :to-fixed

Converts a number to a string with a fixed number of decimal places. Defaults to 2 digits if :digits is not specified.
Works with variables:

Type Coercion: :number

Converts a value to a number. Useful when form inputs are strings that need to be used in calculations.
Works with variables:

Number Formatting: :format-number

Formats a number for display. Use :digits to control decimal precision.

Age Calculation: :age

Calculates age in years from a date value. Typically used as an inline pipe (see Dates & time for the full reference), but also available as an operator in numeric contexts.

Numeric Comparisons

Use :cmp with numeric values for conditional logic based on calculations:
Combining arithmetic with comparison:

Next Steps

Logic & comparisons

Conditional logic with numeric results

Dates & time

Date arithmetic with :sum

Loops & arrays

Aggregate calculations on collections

Variables & scope

Referencing numeric data