Forwarding Address: OS X

Thursday, October 14, 2004

Quick calculator

I had a vague memory that there was a calculator available in OS X from the command line but couldn't remember what it was. Some Googling turned up bc which works just fine as a calculator but from its man page description appears to be so much more than that:
bc is a language that supports arbitrary precision numbers with inter- active execution of statements. There are some similarities in the syntax to the C programming language. A standard math library is available by command line option. If requested, the math library is defined before processing any files.
So a question: if you use a calculator from the command line, what do you use?

16 Comments:

  • I sometimes use bc, but more often I use OpenMCL. I suspect this puts me in the definite minority, though.

    -- Michael Hannemann

    By Anonymous, at 12:20 PM  

  • bc or perl.
    Most times I use google's calulator feature though, which is especially handy for things like "700MB / 90 minutes in kbps".

    By map, at 12:22 PM  

  • I usually use bc, although lately I've been using QuickSilver's built-in calculator since I just have to hit a key to activate it & type a formula.

    By Mike, at 12:54 PM  

  • I use python. -Nathan

    By Anonymous, at 1:36 PM  

  • I've always got Safari open, so I just use the Google calculator in the search field.

    By Anonymous, at 5:38 PM  

  • I use QuickSilver, whhich uses bc. Control-Space, then = and the calculation you want to perform. The results are displayed (by my preference) in a large-type floating bezel.

    By Quine Mondrian, at 6:59 PM  

  • I use Python when at the command line. It has a syntax I'm more comfortable with than bc's. But these days I just use bc via Quicksilver. It's much faster to get to.

    --Jace, http://jace.seacrow.com/

    By Anonymous, at 12:47 AM  

  • I use a nifty Perlbased calculatorscript.

    I'm not sure if it's better than bc or not but there was some reason for the choice originally.

    By Anonymous, at 2:46 AM  

  • Oddly enough the first thing I did when I wanted to use a calculator from the command line was type: calc.

    So I think I'll be installing the perl-driven calc that was previously mentioned and save myself having to rewire my synapses to something else. Thanks for the pointer anonymous.

    By Chris, at 6:28 AM  

  • I use bc for complex stuff (converting between bases, etc), or if I have a lot to calculate. For quick stuff, I just use bash: echo $(( 1024 - 42 ))

    By Anonymous, at 10:18 AM  

  • I use dc, another command-line calculator. It's stack-based and uses RPN notation. I even wrote a clone in awk. *spins propeller hat*

    By Steve Jenson, at 9:39 PM  

  • I'm posting anonymously because I not only use "bc", but I do things like echo a formula into bc:

    echo '2 + 4 * 5 + 2' | bc

    so that I can use command history to repeat formulas. I did it in front of an executive once and when I looked back at him, he had this look of horror like he had just seen someone kill his parents.

    By Anonymous, at 1:14 PM  

  • echo '2 + 4 * 5 + 2' | bcAnonymous: congrats on writing the shortest line of functionally-useful code to make me laugh out loud!

    By Chris, at 2:44 AM  

  • I use bc, and all I do is simple math. Anything else gives me a headache...

    By raster, at 10:18 AM  

  • The bash shell has integer arithmetic evaluation built in.

    $ echo $[ 700/11 ]

    By Anonymous, at 1:17 AM  

  • I use Google, does that count as a command line calculator? :-)

    By Anonymous, at 3:16 PM  

Post a Comment

<< Home