Using fractional exponent with bc

bc , the linux command line calculator, is skilled enough to count

3^2
9

Even a negative indicator does not bother him:

3^-2
0.11111

However, this fails when he encounters

9^0.5
Runtime warning (func=(main), adr=8): non-zero scale in exponent

How can it be that bc does not cope with this?

What does the error message mean?


Yes, I read this and the solution given there:

e(0.5*l(9))
2.99999999999999999998

And yes, it is useless due to loss of accuracy and

The calculator should solve expressions. You should not make the life of a calculator easier, it should be different on the contrary ...


This feature was designed to encourage users to write their own functions. Create a unique calculator that requires a custom function to calculate the square root.

, , s(x) c(x). , , - .

- bc, Python? ?

+10
2

bc - , " ", : , ; , "" wikipedia.

, , , SO.

+4
bc b ^ b. bc :

~/.bcrc, :

define pow(a, b) {
    if (scale(b) == 0) {
        return a ^ b;
    }
    return e(b*l(a));
}

bc :

bc -l <(cat ~/.bcrc)

pow .

, bc.

+2

All Articles