Your question, your audience. Choose who sees your identityâ€”and your questionâ€”with question security.

I was told that: "each UNIX comes with a small program called bc (precision calculator), depending on the (math)libs installed on the system, bc can do the calculation of 4^(10^9)"

Could you please tell me what math libs are needed?

How do I refer to them?

And in general what is the exact command that I need to use to perform that calculation?

Thanks!

Could you please tell me what math libs are needed?

How do I refer to them?

And in general what is the exact command that I need to use to perform that calculation?

Thanks!

but I sugest to try following first:

echo "2^(10^6)" | bc

be prepared for a huge output, but you already know this ;-)

If bc is compiled with a libm which is not sufficient for huge numbers, you get an error message.

To track down this, please post results of:

uname -a

echo 1 | bc -v

# errors produced by suggested commands

While ago, I was asking my students to calculate

2^10^5 using bc. The trick is to avoid

large exponent.

Below shows an example.

The output is piped to wc, so that you can see how

many lines and digits:

echo "(2^1000)^100" | bc | wc

443 443 30988

Good luck.

I am not sure what you mean. 2^10 gives the correct result.

I typed:

uname -a THEN PRESSED ENTER AND THEN TYPED

echo 1 | bc -v THEN PRESSED ENTER AND I DID NOT GET ANY ERRORS

Up until 2^9999 I get a result, but after that I get the following error:

2^10000

exp too big

empty stack

save:args

Any thoughts of what is going on?

thanks for your insight. However, I am not familiar with wc, what is that and where and how can I see the result?

ODY

it just count words, lines and characters, that's all.

About bc's "exp too big":

does uname -a not give you anything?

ich "echo 1|bc" does not produce a string, please simply call:

bc

it should print a version number. You can exit bc by using the quit command.

Sounds that you need another bc.

now I understand, I thought that I had to type these commands while being in bc.

Here is the output:

/prod/users/usm/u58554> uname -a

HP-UX groucho B.11.00 U 9000/800 47704516 unlimited-user license

/prod/users/usm/u58554> echo 1 | bc -v

bc: illegal option -- v

/prod/users/usm/u58554> echo 1|bc

1

/prod/users/usm/u58554>

However, I managed to do 2^(10^6) by writing instead (2^1000)^1000.

Is there anyway that I can have this output get printed on a file?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

echo "(2^1000)^100" | bc |tee 2to100000.txt

or

echo "(2^1000)^100" | bc > 2to100000.txt