Skip to content

Instantly share code, notes, and snippets.

@nicdoye
Created March 2, 2016 23:32
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 nicdoye/bb1738177b8ba3879d9f to your computer and use it in GitHub Desktop.
Save nicdoye/bb1738177b8ba3879d9f to your computer and use it in GitHub Desktop.
Ever wondered what the maximum size of a numeric (10**1000) in PostgreSQL looks like? Here you go. #pretty
p=1000;l=72;t=3;c=",";n="\n";z=0;w=" ";e=f="";P=p%l;(1..(4*l/t-(2+P+(P/t).floor))).each{|i|f+=w};(1..p).each{|i|q=(p-i+1);print(((i==1)?f.to_s+1.to_s():e)+(((q%t== 0)?c+((q%l==0)?n:e):e)+z.to_s)+((i==p)?n:e))};
@davecoutts
Copy link

Are you taking patches for this ? :-)

python -c "import textwrap; print(textwrap.fill(' {:,}'.format(pow(10,1000)),72))"

@nicdoye
Copy link
Author

nicdoye commented Mar 6, 2016

Your version is 40% faster (Python 2.7.11 from homebrew vs Ruby 2.2.1p85 from RVM).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment