This function can be used to turn a value into a real number.
When using this function on a string, numbers, minus signs, decimal points and exponential parts in the string are taken into account, while other characters (such as letters) will cause an error to be thrown. If a string may have other characters then you can use string_digits to remove all non-numeric characters, before using this function to turn the resulting string into a real number.
NOTE Hexadecimal numbers are also supported in a string. These strings should have a format "0x00F".
NOTE This function can also be used to convert some other data types to Real, such as int64.
real(string);
Argument | Type | Description |
---|---|---|
string | String | The string to be converted to a real value. |
var t_str = string_digits(input_str);
age = real(t_str);
The above code will take the input string, strip it of all characters other than numbers and then set the variable "age" to hold the real number value of the return string.