Converts a string (of the given base) to a number
Converts n to a number using the optional base (default 10). Base can be from 2 to 36. For bases > 10 the letters a-z (not case sensitive) represent the digits. (eg. F is 15).
You can use tonumber as a quick check if a variable contains something convertable to a number.
To see if the variable actually is already a number type, use the "type" function:
See also bit.tonumber which will handle larger numbers.
See Also ...
assert - Asserts that condition is not nil and not false
Lua base functions
(Help topic: lua=tonumber)
Enter a search string to find matching documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.
Gammon Software support
Forum RSS feed ( https://gammon.com.au/rss/forum.xml )