number

Converts text to a number: a form's values are text, and arithmetic on text is unreliable. The text may carry a sign, digits, a decimal point and an exponent, with spaces around it; anything else (a currency sign, a thousands separator, letters) makes it not a number, and the default is returned. A number given as the value is returned as it is.

Runs on: either side: the compiler places the statement that calls it where the values it uses live.

Format:

number(value [, default])

Parameters:

Parameter Type Description
value mixed the text (or number) to convert
default number  [Optional]the result when the value is not a number; 0 unless given

Returned Value:

Type Description
number the number, or the default

Examples

qty = number(get_form_values(order_form).quantity, 1)