By Daniel · March 21, 2009
Generates a string representation of an integer using the specified base
// toString(n, radix)
var n, l, s, r;
n = abs(argument0); r = argument1; s = "";
l = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
while (n) {
s = string_char_at(l, n mod r + 1) + s;
n = n div r;
}
return (sign(argument0) == -1) * '-' + s;
Categories: Data processing, Mathematics, String handling
There are no comments to display.
You must be signed in to post comments.