S2I

Parameters
s string

The string to be converted.

comment

Returns an integer by parsing the string for a number.

For values too big or too small, returns max/min integer respectively. For an empty string or text that doesn't start with a number, returns 0.

Lua: For null raises an error.

Examples (Lua):

S2I("") == 0
S2I("-123") == -123
S2I("-99999999") == -2147483648
S2I("99999999") == 2147483647
S2I("123abc") == 123
S2I("abc123") == 0
S2I(nil) -- error
note

This function only works for decimal strings. Hexadecimal or octal strings are not supported.

note

The parser stops at the first non-number character [0-9.]. If the input string starts with some valid input but ends in invalid input this will return the conversion of the valid part: S2I("123asd") == 123.

patch

1.00

pure
This function is pure. For the same values passed to it, it will always return the same value.
return type
integer
Source code
native S2I  takes string s returns integer
Source
common.j
wc3modding.com
S2I