GOLF(2gg)

NAME
string-number - (numbers)

PURPOSE
Convert string to number.

SYNTAX

        string-number <string> [ to <number> ] \
            [ base <base> ] \
            [ status <status> ]

DESCRIPTION
<string> is converted to <number> in "to" clause, using <base> in "base" clause, where <base> is by default either 10, or 16 (if number is prefixed with "0x" or "0X", excluding any leading minus or plus sign) or 8 (if number is prefixed with "0", excluding any leading minus or plus sign).

<base> can be between 2 and 36, inclusive. <number> can be positive or negative (i.e. signed) and can be up to 64-bit in length. If <base> is 0, it is the same as if it is not specified, i.e. default behavior applies.

<status> number (in "status" clause) is GG_OKAY if conversion was successful. If it wasn't successful, <number> is 0 and <status> is GG_ERR_OVERFLOW if <string> represents a number that requires over 64 bits of storage, GG_ERR_INVALID if <base> is incorrect, GG_ERR_EXIST if <string> is empty or no digits specified.

If there are trailing invalid characters (for instance "182xy" for base 10), <number> is the result of conversion up to the first invalid character and <status> is GG_ERR_TOO_MANY. In this example, <number> would be 182.

EXAMPLES
In this example, number "n" would be 49 and status "st" would be GG_OKAY:

        string-number "49" to n base 10 status st

SEE ALSO
 Numbers

abs-number number-expressions number-string set-number string-number See all documentation