A lot of people say that Unix BC is a very good calculator program. However whenever I enter the following commands (after loading the math library -- i.e invoking BC at the command line by typing 'bc -l') I get:

e (3 * l(2) )

The first one is computing 2^3 which should be 8.
The second equation is computing 32^0.2 (or the fifth root of 32) which should be 2.

I know the numbers are off by a little bit, but it does get a little annoying, especially when people say the program is the best at arbitrary precision arithmetic (and other worse programs can do better).

Does anyone know why this happens? How can I fix this? Or, is there a better command-line calculator program I can use?

9 Years
Discussion Span
Last Post by Dark_Knight

>people say the program is the best at arbitrary precision arithmetic

It may not be the best, but it's definitely one of the better ones. It's just how floating point precision works. You get a larger range, but the precision goes way down.

What you're looking for is an exact precision calculator. Sorry, I don't know of any -- I save all my calculations for my real (physical) scientific calculator(s). Google is your friend, as usual.


Why not just type 2^3 ? You still get 8. Maybe it's because you're using more complex functions, and as John A said, the range is large with bc, but the precision goes down.

I've never had a problem with bc before in my life.


Why not just type 2^3 ?

I know I can type 2^3 , but I can't type 32^0.2 because bc can only compute exponents of integer powers. Which is why I am using the exponential and natural logarithm functions to compute exponents of arbitrary powers (e.g. 3.2 ^ 1/5).

Anyway, I'll keep looking for a good command line calculator program (personally I hate the fancy graphical calculators that look like hand-held calculators, I'd rather type in my equations).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.