@to_num(string)
@to_num(tab)
converts a string into a numeric value (integer or float, following the
most appropriate). If the argument is a tab, the function applies
implicitly to each element of the tab. Value <undef>
is
returned if the argument is not a string nor a tab.
If the string does not represents an arithmetic expression, the value not-a-number (NaN) is returned. This value can be tested using the predicate [@is_nan()]. Beware that not-a-number values are floating point values but their comparaison returns always false (they must be tested using [@is_nan()]).
The string may contains parenthetised arithmetic expressions with
addition, substraction, multiplication and division between integers and
floating point values. Floating point values can be written in decimal
form or in engineering notation (like +6.3e-12
).
If the expression is not a well formed parenthetised arithmetic expressions, not-a-number is returned. If a division by 0 occurs during the course of the computation, the infinity value is returned and processed subsquently in the rest of the expression. The calculation rules are the rules using for ieee floating point expressions.
See also @parse and String Management @car, @cdr, @char_is_alnum, @char_is_alpha, @char_is_ascii, @char_is_blank, @char_is_cntrl, @char_is_digit, @char_is_graph, @char_is_lower, @char_is_print, @char_is_punct, @char_is_space, @char_is_upper, @char_is_xdigit, @copy, @count, @drop, @dump, @dumpvar, @empty, @explode, @find, @is_prefix, @is_string, @is_subsequence, @is_suffix, @last, @member, @occurs, @parse, @permute, @push_back, @r_compile, @r_findall, @r_match, @r_search, @remove, @remove_duplicate, @replace, @scramble, @slice, @sort, @sputter, @string2fun, @strip_path, @stutter, @string2proc, @system, @take @to_num, @Tracing, @UnTracing