Carrot reference
Functions

number()

Given a value, returns that value as a Number.

Syntax

number(value)

  • value - the Number, Money, Percent, Enum, Boolean, or String value to be converted by the function.
  • Return type: Number

Sample usage

number($100) returns 100.

number(string(base)) returns the original value of base.

Supported data types

Input type

Return type

Logic

Number

Number

If a Number value is passed, the same Number value will be returned.

Money

Number

If a Money value is passed, the amount will be returned as a Number.

Percent

Number

If a Percent value is passed, the amount will be returned as a Number of subtype Decimal where 50% is equivalent to .5.

Enum

Number

If a numeric scale Enum value is passed, the numeric value is returned as a Number.

Boolean

Number

If a Boolean value is passed, true will return the Number value 1, and false will return the Number value 0.

String

Number

If a String value is passed, its constituent characters will be evaluated for compatibility with the Number data type. Characters which are compatible will be returned as a Number value. If two or more sets of compatible characters are separated by non-compatible characters (ex. "121yes121"), the compatible sets of characters will be returned as comma-separated values (ex. 121,121)

Unsupported data types

Null

Unsupported data types return Null.



Updated 04 Oct 2023
Doc contributor
Did this page help you?