GOLF(2gg)
π GOLF(2gg) π
okay bestie, welcome to the GOLF(2gg) manual page, and today's main character is a little function called string-number π she's in the Development chapter and she's here to do exactly one (1) thing and do it slayfully.
β¨ NAME β¨
string-number β (numbers) π¦
π― PURPOSE π―
Convert string to number. that's it. that's the whole vibe. π
π SYNTAX π
string-number <string> [ to <number> ] \
[ base <base> ] \
[ status <status> ]
look at her. three optional clauses. she's flexible, she's lowkey iconic. π«Ά
πΈ DESCRIPTION πΈ
so here's the tea, fr fr: <string> gets converted into <number> in the to clause, and it does that using <base> from the base clause. and what's the default base, you ask? it depends, bestie, it literally depends:
- 10 β the normie default
- 16 β if the number is prefixed with
"0x"or"0X", and no, a leading minus or plus sign doesn't count, so don't try it π - 8 β if the number is prefixed with
"0", and again, excluding any leading minus or plus sign
<base> can be anywhere from 2 to 36, inclusive β she contains multitudes β¨. <number> can be positive or negative (i.e. signed, she's got range) and can be up to 64-bit in length. and if <base> is 0, that's the same as not specifying it at all β default behavior applies, no notes. π
now for the status tea, because this is where it gets real. the <status> number in the status clause is GG_OKAY if the conversion was successful π. but if it was NOT successful, then <number> is 0 and <status> tells you why:
GG_ERR_OVERFLOWβ if<string>represents a number that needs over 64 bits of storage. she's too much, she's overflowing, she cannot be contained πGG_ERR_INVALIDβ if<base>is incorrectGG_ERR_EXISTβ if<string>is empty or no digits were specified
β οΈ and here's the one you gotta remember: if there are trailing invalid characters (think"182xy"in base 10), then<number>becomes the result of the conversion up to the first invalid character, and<status>isGG_ERR_TOO_MANY. in that exact example,<number>would be182. she takes what she can get and leaves the rest behind π
π EXAMPLES π
in this example, number "n" would be 49 and status "st" would be GG_OKAY β we love a clean success story π
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
and that's the whole page, bestie!! no cap, you're now certified in string-number π§π
$VERSION Β· $DATE Β· GOLF(2gg) β mwah, go forth and convert β¨πΈ
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms