toNumber
Table of Contents
Overview
The toLong function takes an expression as an argument, and returns a number.
Note:
- Decimals when subjected to the toNumber function will lose their fraction parts. Use toDecimal instead.
- If a piece of text has alphanumeric data(say, 1000abc) in it, then toNumber function will throw an error message.
Return Type
- NUMBER
Syntax
<variable> = <expression>.toNumber();
(OR)
<variable> = toNumber(<expression>);
(OR)
<variable> = <expression>.toLong();
(OR)
<variable> = toLong(<expression>);
where,
Parameter | Data type | Description |
<variable> | NUMBER | Variable which will contain the converted number. |
<expression> | NUMBER/DECIMAL/DATE-TIME/TEXT | The expression which will resolve to a number. Note:
|
Examples
decimal = 123.25; info decimal.toNumber(); // Converts the decimal into a number and returns 123
num_text = "1234"; info num_text.toNumber(); // Returns 1234
alpha_text = "134A123B"; info alpha_text.toNumber(); // Returns error