Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Yet another command line calculator' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Yet another command line calculator
Authored by: mkhaw on Feb 02, '05 11:01:10AM

One could also use the Unix 'bc' calculator program, which supports C-like expressions including control flow and function definitions. Try 'man bc' for details.

From a shell prompt you can say things like:

csh% echo '3*4' | bc
12
csh%



[ Reply to This | # ]
Yet another command line calculator
Authored by: ericasadun on Feb 02, '05 12:37:22PM

You can use bc interactively, line-by-line.

There's also "dc" which is reverse polish.



[ Reply to This | # ]
Yet another command line calculator
Authored by: zojas on Feb 02, '05 01:37:49PM

the cool thing is that bc is 'infinite' precision. try this:

bc -l
2^100
1267650600228229401496703205376

yup, that's 2 raised to the 100th power!

the -l flag turns on floating point stuff, to 20 decimal place precision.



[ Reply to This | # ]
Yet another command line calculator
Authored by: nicholst on Apr 09, '06 10:54:44AM
Why bother with echo? With this alias

alias calc bc -lq

I always have a calculator handy.

The -l option is important, otherwise you only get integer arithmatic. (-q just silences the FSF warning).

-T

[ Reply to This | # ]