Here's a tip to have a calculator readily avaiable from
the OS X Terminal. If you always have a Terminal window
open, this is easier than using Apple's calculator or even
the Tiger Dashboard:
1) Open a new terminal window
2) Copy/paste the following code. You can add this to
your ~/.profile to make it available in future Terminal
windows.
function calc () {
echo $* | bc -l
}
3) Now you have a calculator always available. Use quotes
if you're using parenthesis. This calculator is also
infinite-precision. See the last example showing pi to
400 digits.
% calc 19.99*1.0825
21.6391
% calc "e(1)"
2.71828182845904523536
% calc "s(0.45)^2+c(0.45)^2"
.99999999999999999997
% calc "scale=400;a(1.0)*4"
3.141592653589793238462643383279502884197169399375105820974944592307\
81640628620899862803482534211706798214808651328230664709384460955058\
22317253594081284811174502841027019385211055596446229489549303819644\
28810975665933446128475648233786783165271201909145648566923460348610\
45432664821339360726024914127372458700660631558817488152092096282925\
40917153643678925903600113305305488204665213841469519415116092
Alex
|