Page 1 of 1

PHP & Order of Operations

Posted: Fri Apr 16, 2004 9:07 pm
by tonic889
Alright, seemingly simple problem here:

I have this line of code:

Code: Select all

<?php

echo ((1.12*(1.40^2))*(.91^2));

?>
The output I receive is 6.72. When I take this formula and paste it into Excel (as well as do it with a calculator myself), I get an entirely different answer (1.81784512). Is anyone else able to recreate this problem? Does PHP follow order of operations differently than the rest of the world or have I been awake for too many hours in a row?

Posted: Fri Apr 16, 2004 9:12 pm
by Ixplodestuff8
I'm not sure if php can use a ^ for exponets, try using the pow function

Posted: Fri Apr 16, 2004 9:19 pm
by tonic889
Ah...there we go. I knew it had to be something simple. Thanks.