Game Maker Games, Articles, Tutorials & More

Game Maker Network


Howdy, Guest! Please sign in or register an account.

Print

toString

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;

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement