View/Edit #29:group_number

Switch to edit mode.

Name(s): group_number
1:  "$string_utils:group_number(n [, sep_char])"
2:  ""
3:  "Converts N to a string, inserting commas (or copies of SEP_CHAR, if given) every three digits, counting from the right.  For example, $string_utils:group_number(1234567890) returns the string \"1,234,567,890\"."
4:  n = args[1]
5:  comma = length(args) > 1 ? args[2] | ","
6:  result = ""
7:  sign = n < 0 ? "-" | ""
8:  n = tostr(abs(n))
9:  while ((len = length(n)) > 3)
10:   result = comma + n[len - 2..len] + result
11:   n = n[1..len - 3]
12: endwhile
13: return sign + n + result

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Hacker (#60)

You are not logged in.

[home | help | who | search | setup | code]