str_to_num (STRING*)
str_to_int (STRING*)
str_to_float (STRING*)
Returns a number converted from a string.
Parameters:
STRING* - STRING pointer to be read.
Returns:
Numerical value of the string as a var, long, or double value, or 0 if the string is non-numerical.
Speed:
Fast
Remarks:
- LC A7.2 Use str_to_int or str_to_float for reading numbers that exceed the var range or precision.
- A7.72
The result variable is set to 0 when the string does not contain a valid float or integer number, otherwise it's nonzero.
Example:
STRING* s = "3.1415926";
...
var vpi = str_to_num(s); // vpi == 3.142
float fpi = str_to_float(s); // fpi == 3.1415926
See also:
str_for_num,
str_setchr, str_getchr
► latest
version online