This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
number_parsing [2017/03/21 14:05] – created korshun | number_parsing [2017/03/21 14:28] (current) – korshun | ||
---|---|---|---|
Line 2: | Line 2: | ||
ACSUtils provides functions to convert strings to numbers. | ACSUtils provides functions to convert strings to numbers. | ||
- | Simple functions | + | ===== Bases ===== |
+ | 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: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | For example, '' | ||
+ | |||
+ | 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. | ||
+ | |||
+ | ===== Errors ===== | ||
+ | The following errors can happen while parsing a number: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | |||
+ | |||
+ | ===== Simple functions | ||
+ | |||
+ | These simply return 0 on error, b: | ||
* [[functions: | * [[functions: | ||
* [[functions: | * [[functions: | ||
- | Complex functions: | + | ==== Examples ==== |
+ | |||
+ | < | ||
+ | atoi(" | ||
+ | atof(" | ||
+ | atoi(" | ||
+ | </ | ||
+ | |||
+ | ===== Complex functions | ||
+ | These return error status and result, and allow specifying an arbitrary base: | ||
* [[functions: | * [[functions: | ||
* [[functions: | * [[functions: | ||
+ | Error statuses are: | ||
+ | | ||
+ | ==== Examples ==== | ||
+ | < | ||
+ | ParseInt(" | ||
+ | r1 -> PARSENUMBER_SUCCESS | ||
+ | r2 -> 123 | ||
+ | |||
+ | ParseInt(" | ||
+ | r1 -> PARSENUMBER_SUCCESS | ||
+ | r2 -> 8 | ||
+ | ParseInt(" |