@to_num(numeric)
@to_num(string)
@to_num(tab)
converts its argument into a numeric value (integer or float, following the most appropriate).
If the argument is a number, this number is the value returned.
If the argument is a string representing an arithmetic expression, the
function returns the result of this expression.
If the argument is a tab, the function applies
implicitly to each element of the tab. Value <undef>
is
returned in the other case.
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 (NaN) 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.
If the string does not represents an arithmetic expression, the NaN value is also returned 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()]).
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 @split @sputter @string2fun @string2proc @strip_path @stutter @system @take @to_num @Tracing @UnTracing
Most functions acting on tabs operate also on strings.