ACSUtils provides functions to convert strings to numbers.
The parsed numbers can be written in any base from 2 to 36. In bases over 10, letters of the alphabet are used as digits.
If a base is not explicitly specified or is set to 0, base prefixes can be used:
0x
– base 160o
– base 80b
– base 2
For example, "0xFF"
is parsed as 256.
If no base prefix is present, base 10 is used by default
If a base is specified when parsing the number, base prefixes are not supported and their presence is treated as error.
The following errors can happen while parsing a number:
PARSENUMBER_SUCCESS
– no errorPARSENUMBER_BADFORMAT
- the number could not be parsed at all.atoi("123") -> 123 atof("123.456") -> 123.456 atoi("abc") -> 0
These return error status and result, and allow specifying an arbitrary base:
Error statuses are:
<code> ParseInt(“123”, 0); r1 → PARSENUMBER_SUCCESS r2 → 123
ParseInt(“10”, 8); In base 8 r1 → PARSENUMBER_SUCCESS r2 → 8 ParseInt(“999999999