File: string-number.2gg

package info (click to toggle)
golf 601.4.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,824 kB
  • sloc: ansic: 20,020; sh: 1,171; makefile: 292
file content (48 lines) | stat: -rw-r--r-- 1,626 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
string-number \-  (numbers)
.SH PURPOSE
Convert string to number.

.SH SYNTAX

.RS 4
.EX

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

.EE
.RE

.SH 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.

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

.RS 4
.EX

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

.EE
.RE

.SH SEE ALSO
 Numbers

\fBabs-number\fP  
\fBnumber-expressions\fP  
\fBnumber-string\fP  
\fBset-number\fP  
\fBstring-number\fP   
See all 
\fBdocumentation\fP