in reply to Re: Simple command line calculator
in thread Simple command line calculator

It doesn't do floating point, though, which is why I often do use perl in non-debugging interactive mode or use a one-liner.
perl -e 'print 5/2, "\n"';
I like getting `2.5' there instead of just `2'.

Or, just do this:
# perl
which will let you type a program into STDIN for perl to execute. Perfect if you need to make three or four calculations.

Replies are listed 'Best First'.
Re: Re: Re: Simple command line calculator
by jmcnamara (Monsignor) on Mar 27, 2002 at 09:03 UTC

    It doesn't do floating point, though

    It does do floating point. Although, by default bc shows the results of calculations as integers. However, that can be changed either by setting scale or by invoking it with the -l option:

    $ bc 5/2 2 scale=4 5/2 2.5000 $ bc -l 5/2 2.50000000000000000000

    --
    John.