Number | FLOAT

Syntax

FLOAT( [input], [default = 0 ] )

Parameters

input
Any data may be used as the input.

default optional
If input cannot be converted to a number, default is returned. default must be a number.

Return Value

The result of the input being converted to a number.

Description

Where possible, any value passed into this method will return a number. The default value is used if the input cannot be converted to a number. The method will return 0 if the default number also cannot be converted to a number.

Examples

FLOAT(1) # returns 1
FLOAT(1.5) # returns 1.5
FLOAT("1") # returns 1
FLOAT("1.5") # returns 1.5
FLOAT("not a number") # returns 0
FLOAT("not a number", 1.5) # returns 1.5
FLOAT("not a number", "not a number") # returns 0