Tonumber()

From Riftui Wiki

Jump to: navigation, search

Converts a string of digits into a number. The base is optional and defaults to base 10.

x = tonumber("1234", [base])

Examples

The basic use of tonumber:

x = tonumber("1234")
print(type(x))
-- Prints "number" to the chat window

The function will also accept scientific notation:

x = tonumber("1e3")
print(type(x),x) 
-- Prints "number	1000" to the chat window

Hex numbers can be converted by including the base in the function call:

x = tonumber("19a5",16)
print(x) 
-- Prints "6565" to the chat window
Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox