From: Simon Ruderich Date: Mon, 1 Apr 2013 21:22:37 +0000 (+0200) Subject: bin/calc: Add s() to convert number to scientific notation. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=88997f09e4b2e6ce41c374495af0818036a2d627;hp=5ce0b37429d5311d52568524c7a07785c95c97de;p=config%2Fdotfiles.git bin/calc: Add s() to convert number to scientific notation. --- diff --git a/bin/calc b/bin/calc index c364119..9fa35d3 100755 --- a/bin/calc +++ b/bin/calc @@ -27,6 +27,10 @@ def ld(x): def binom(n,k): return reduce(lambda a,b: a*(n-b)/(b+1),xrange(k),1) +# Convert number to scientific notation (e.g. 5e6). +def s(x): + print "%e" % x + # Time/Date functions. import time