bc, a Linux command-line calculator, is proficient enough to calculate
3^2
9
Even a negative exponent doesn't confuse it:
3^-2
0.11111
Yet it fails when it encounters
9^0.5
Runtime warning (func=(main), adr=8): non-zero scale in exponent
How could it be that bc can't handle this?
And what does the error message mean?
Yes, I've read this and the solution given there:
e(0.5*l(9))
2.99999999999999999998
And yes, it is no good because of precision loss and
A calculator is supposed to solve expressions. You are not supposed to make life easier for the calculator, it is supposed to be the other way around...
This feature was designed to encourage users to write their own functions. Making it a unique calculator that requires a user-defined function to calculate a square root.
It doesn't really bother me to write a function for tangents or cotangents as it looks pretty straightforward given s(x)
and c(x)
. But in my opinion calculating a square root through a user-defined function is a bit too much.
Why anyone uses bc if there's Python out there? Speed?
bc is very basic and more complex functions not provided by the "math extension" must be implemented in the language itself: it has all you need to do it; in particular "power" is a common example even on wikipedia.
But you may be also interested in reading for example this answer here on SO.