]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
bin/calc: Add s() to convert number to scientific notation.
authorSimon Ruderich <simon@ruderich.org>
Mon, 1 Apr 2013 21:22:37 +0000 (23:22 +0200)
committerSimon Ruderich <simon@ruderich.org>
Mon, 1 Apr 2013 21:22:37 +0000 (23:22 +0200)
bin/calc

index c3641191956eded9510788bf714523669d360aac..9fa35d378dab8a69f508cf2529c04a29aded4a18 100755 (executable)
--- 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