This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
mibac138's profile picture

How to change string to number (int) ?

Started by mibac138, 26 May 2013 - 01:09 PM
mibac138 #1
Posted 26 May 2013 - 03:09 PM
As I say in topic, my question is: How to change string to number?


Please help!
Xenthera #2
Posted 26 May 2013 - 03:20 PM
tonumber(string)
mibac138 #3
Posted 26 May 2013 - 03:24 PM
ohhhh, thanks forgot about this :/
theoriginalbit #4
Posted 26 May 2013 - 11:16 PM
also it should be noted that the `tonumber` function can also accept a radix.

tonumber( [string], [radix] )
So something like
tonumber("f", 16)
would convert the hexadecimal `f` (base-16) into decimal `15` (base-10)