GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’– GOLF(2gg) β€” the number-string page, bestie edition πŸ’–

okay so this is from the GOLF(2gg) manual, Development section, and it's literally all about turning numbers into strings. no cap. let's get into it 🫢


✨ NAME ✨

number-string β€” (numbers)


πŸŽ€ PURPOSE πŸŽ€

Convert number to string. that's it. that's the whole job. iconic behavior honestly πŸ’…


πŸ¦‹ SYNTAX πŸ¦‹

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

look at her. so structured. so slay ✨


🌸 DESCRIPTION 🌸

so here's the tea, bestie: <number> gets converted into <string>, and that lands in the to clause. the conversion uses <base> from the base clause, and <base> defaults to 10 if you don't say otherwise. <base> can be anywhere between 2 and 36, inclusive β€” like, both ends count, don't come for me πŸ”₯

<number> can be positive or negative (so yes, signed, she contains multitudes πŸ’œ) and can be any integer type up to 64-bit β€” char, int, long, long long, etc. etc. you get the vibe. and if the to clause is omitted, then <number> just gets printed out. main character moment for a number, honestly πŸ‘‘

okay important: any letters in <string> (which depends on the <base>, iykyk) are always lower-case. always. no uppercase shenanigans. periodt. πŸ’…

if there's an error β€” like if <base> is incorrect or whatever β€” then the <status> number (in the status clause) is GG_ERR_FAILED. otherwise it's GG_OKAY. so you always know where you stand, bestie 😌

using number-string (and the print-out that's based on it) for converting and outputting numbers is high-performance and recommended if your application needs to do that a lot. like, if you're doing this constantly, this is the move, fr fr. and if number-string prints out a number (meaning the to clause is omitted) and this happens within write-string, then <number> is output into the buffer that builds a new string. cute, right? πŸŽ€


🌈 EXAMPLES 🌈

this one allocates memory for string "x" to be "801":

set-number x = 801
number-string x to res

and this one stores "-238f" into string "res":

set-number x = -9103
number-string x to res base 16

and to print out a number, -131:

set-number x = -131
number-string x

ate that. no crumbs. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

  • Numbers

also go check out: abs-number, number-expressions, number-string, set-number, string-number β€” and See all documentation if you want the whole cinematic universe πŸ’–


mwah πŸ’‹ that's the page! this gorgeous little manual page is sourced from version $VERSION and dated $DATE β€” GOLF(2gg) forever, bestie πŸ¦‹βœ¨πŸ’…

πŸ“¦ where this page comes from