TONUMBER function

TONUMBER(value) TONUMBER(value)

value — Number, Logical, Text, Color, { Number }, { Logical }, { Text } or { Color }

The value to convert.

Returns — Number or { Number }

A number corresponding to the given value.

Returns the given value converted to a number. TONUMBER("42")TONUMBER("42") returns 42.

When the sole parameter is a number, it is returned unchanged. When it is a logical value, FALSE is converted to 0 and TRUE is converted to 1.

When the value is a text string, a direct conversion is attempted (meaning that "42.1" is converted to 42.1), and an error is returned if the conversion is unsuccessful (meaning that "test" cannot be converted to a number, nor can "test4"). The empty text string is converted to 0.

The language settings of the app are taken into account when converting text strings, meaning that an app configured to use German is expected to use a decimal comma (",") as a decimal separator and an app configured to use Australian English is expected to use a decimal point ("."). Thousands separators must not be used and negative numbers must use a leading minus sign ("-"). Use PARSENUMBER instead to parse a numeric text string that uses thousands separators and leading and trailing units.

Colors are converted as though the number is a raw color value. Such a value is a a 32-bit number incorporating color components adhering to the ARGB color model. The least significant eight bits represent the blue color component, the next eight bits represent the green color component and the eight following bits represent the red color component. The most significant eight bits represent the alpha value, where a value of 0 means that the color is fully transparent and a value of 255 means that the color is fully opaque.

This function is specific to Calcapp.

Examples

TONUMBER("42.1")TONUMBER("42.1")

Returns 42.1, if the decimal separator of the language the app is configured to use is a decimal point. If the decimal separator is a decimal comma, an error is returned.

TONUMBER("42,1")TONUMBER("42,1")

Returns 42.1, if the decimal separator of the language the app is configured to use is a decimal comma. If the decimal separator is a decimal point, an error is returned.

TONUMBER("$4,234.10")TONUMBER("$4,234.10")

Returns an error, because TONUMBER cannot handle leading units or thousands separators. Use PARSENUMBER to parse such numbers.

PARSENUMBER("$4,234.10")PARSENUMBER("$4,234.10")

Returns 4234.1, if the decimal separator of the language the app is configured to use is a decimal point. If the decimal separator is a decimal comma, an error is returned. PARSENUMBER can handle leading and trailing units as well as thousands separators, unlike TONUMBER.

TONUMBER(FALSE)TONUMBER(FALSE)

Returns 0.

TONUMBER(TRUE)TONUMBER(TRUE)

Returns 1.