Skip to content

Instantly share code, notes, and snippets.

@gkatsev
Created August 29, 2012 05:26
Show Gist options
  • Save gkatsev/3507093 to your computer and use it in GitHub Desktop.
Save gkatsev/3507093 to your computer and use it in GitHub Desktop.
(function (n) {
var f = '',
s = n < 0 ? '-' : f,
p = [],
l = 0,
m = 4294967296,
o = m * 1024,
a = Math.floor;
o *= o;
n = a(s ? -n : n);
while (n >= o) {
p[l++] = 0;
n /= m;
}
while (n >= m) {
p[l++] = n - (r = a(n / m)) * m;
n = r;
}
p[l++] = n;
do {
r = 0;
i = l;
while (0 <= --i)!(p[i] = a((n = p[i] + r * m) / 10)) && (i + 1 === l) && l--, r = n % 10;
f = r + f;
} while (l);
return s + f;
})(Number.MAX_VALUE)
(function(n){var f='',s=n<0?'-':f,p=[],l=0,m=4294967296,o=m*1024,a=Math.floor;o*=o;n=a(s?-n:n);while(n>=o){p[l++]=0;n/=m;}while(n>=m){p[l++]=n-(r=a(n/m))*m;n=r;}p[l++]=n;do{r=0;i=l;while(0<=--i)!(p[i]=a((n=p[i]+r*m)/10))&&(i+1===l)&&l--,r=n%10;f=r+f;}while(l);return s+f;})(Number.MAX_VALUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment