HyperMath

Conversion

Conversion

Previous topic Next topic No expanding text in this topic  

Conversion

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

You can convert strings to numbers using the function tonumber().  This takes a string argument and returns a number.

> print(tonumber("123") + 25)

148

 

> x = tonumber("123.456e5")

> print(x)

12345600

If a non-number string is passed, the tonumber() function returns "nil".

> x = tonumber("hello")

> print(x)

nil