Garry's Mod Wiki

Revision Difference

Global.tonumber#565061

<function name="tonumber" parent="Global" type="libraryfunc"> <description> Attempts to convert the value to a number. </description> <realm>Shared and Menu</realm> <args> <arg name="value" type="any">The value to convert. Can be a number or string.</arg> <arg name="base" type="number" default="10">The base used in the string. Can be any integer between 2 and 36, inclusive.</arg> </args> <rets> <ret name="" type="number">The numeric representation of the value with the given base, or <page>nil</page> if the conversion failed.</ret> </rets> </function> ⤶ <example>⤶ <description>Convert a string to a number.</description>⤶ <code>print(tonumber("123"))</code>⤶ <output>123</output>⤶ </example>⤶