Skip to content

Instantly share code, notes, and snippets.

@dbrockman
Created January 12, 2014 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbrockman/8387174 to your computer and use it in GitHub Desktop.
Save dbrockman/8387174 to your computer and use it in GitHub Desktop.
var digits = '0123456789' +
'abcdefghijklmnopqrstuvwxyz' +
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'-_';
var radix = digits.length;
function shorten_number(n) {
var s = '';
while (n > 0) {
s = digits.charAt(n % radix) + s;
n = Math.floor(n / radix);
}
return s || '0';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment