Attempts to convert a variable as a number. |
||
Syntax |
n = tonumber(v) |
|
Argument |
Name |
Description |
|
v |
A variable of any type. |
Outputs |
Name |
Description |
|
n |
A number or a matrix of numbers. |
Example |
Syntax |
|
|
print(tonumber(true)) print(tonumber(1)) print(tonumber(0+1i)) print(tonumber([1])) print(tonumber([0+1i])) print(tonumber('hml1')) print(tonumber('NaN')) print(tonumber('Inf')) print(tonumber('-Inf')) |
|
Comments |
n = tonumber(v) attempts to convert the input argument as a number. If it is not possible, it returns a nil value. |
|
See Also: |