Reputation: 101
Is there a function in Lua which allows to convert a hex number to a decimal number?
Upvotes: 8
Views: 31548
Reputation: 72352
Use tonumber
to convert from strings to numbers.
Both these print 2014
:
print(tonumber("0x7DE"))
print(tonumber("7DE",16))
You can also use hexadecimal constants directly:
print(0x7DE)
Upvotes: 22