Welcome to the Linux Foundation Forum!

bc Calculator

Options

Hello, everybody!

I have used the bc calculator, but I get the following message when I try to perform 2^1.5:

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

How could I fix it up?

Thank you in advance!

Comments

  • Posts: 3

    Hey @felipeabrao, welcome!

    The bc calculator only supports integer exponents by default. That’s why 2^1.5 throws the non-zero scale in exponent warning—it can’t handle fractional powers like 1.5.

    To work around this, you can use bc with the math library (-l flag) and rewrite the expression using logarithms and exponentials. Here's how:

    1. echo "e(1.5 * l(2))" | bc -l

    This computes 2^1.5 using the identity:
    x^y = e(y * ln(x))

    Let me know if you want to keep using bc for more complex math or switch to something like awk or Python for better floating-point support.

    Cheers!

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training