This is an old revision of the document!
Number parsing functions parse strings like “123”, “3.14” or “0xff” and return an integer or fixed-point number of the same value.
Simple number parsing functions return 0 if the input string cannot be parsed as a number, and return the minimum or maximum possible value (INT_MIN or INT_MAX) if the input string is a number beyond value limits of ACS variables.
int atoi(str s) parses a string as integer and returns its value.fixed atof(str s) parses a string as a fixed-point number and returns its value.
fixed numbers have a limited precision after the point. atof tries to parse fixed-point numbers to the best precision, but is biased toward 0.
Number parsing functions parse the following number format:
<sign> <base prefix> <digits><sign> <base prefix> <digits> . <digits>There must be no spaces in the string, not even around the number.
Sign can be +, -, or nothing (equivalent to +_.
Base prefix can be one of the following:
0x – base 16 (case-insensitive)0o – base 80b – base 2int, int ParseInt(str s, int default_base)int, fixed ParseFixed(str s, int default_base)Advanced number parsing functions return two values. The first one is a status code, and the second is parsing result:
PARSENUMBER_SUCCESS – no errors happened while parsing the number. The second value is the parsed numberPARSENUMBER_OVERFLOW – the value is out of range limits of int. The second value is either INT_MIN or INT_MAX, depending on the sign of the input number.PARSENUMBER_BADFORMAT – the input string doesn't conform to the format. The second value is 0.
The parameter default_base sets the default base to parse the number in. Bases up to 36 are supported, using the following digits: 0123456789abcdefghijklmnopqrstuvwxyz. Digits beyond 9 are case-insensitive. Any default base can be overridden by a base prefix.