X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=bin%2Fcalc;h=ea3cbd38254bbb4f077b6ac0a238f0a9a7ead69a;hb=7c065655225e7e80c3aa11561b0d97daa2880ae4;hp=c3641191956eded9510788bf714523669d360aac;hpb=a0e89499b7a01724b8a2806805d8432e30e4aace;p=config%2Fdotfiles.git diff --git a/bin/calc b/bin/calc index c364119..ea3cbd3 100755 --- a/bin/calc +++ b/bin/calc @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2011-2013 Simon Ruderich +# Copyright (C) 2011-2014 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,6 +16,8 @@ # along with this program. If not, see . +set -eu + exec python -i -c ' # Math functions. @@ -23,10 +25,16 @@ from math import * def ld(x): return log(x)/log(2) +def lg(x): + return log10(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