Jo Do Jo Do - 8 months ago 47
PHP Question

How can I do this calculation in php?

I want to do this calculation in PHP:


If I run this through a calculator the result is
(I want to round it to

I ran this in PHP

echo round(10000*(0.011*(1.1^148)), 1);

and the output was
. Why does it show a completly different result from my calculator? What can I change to make the result to

Answer Source

The exponential expression is used as function and not with caret as shown below:

$sum = 10000*(0.011*pow(1.1, 148));

echo round($sum, -4);

I've also corrected your rounding for the desired output.