PHP & Order of Operations

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tonic889
Forum Newbie
Posts: 8
Joined: Fri Apr 16, 2004 9:07 pm

PHP & Order of Operations

Post 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?
User avatar
Ixplodestuff8
Forum Commoner
Posts: 60
Joined: Mon Feb 09, 2004 8:17 pm
Location: Queens, New York

Post by Ixplodestuff8 »

I'm not sure if php can use a ^ for exponets, try using the pow function
tonic889
Forum Newbie
Posts: 8
Joined: Fri Apr 16, 2004 9:07 pm

Post by tonic889 »

Ah...there we go. I knew it had to be something simple. Thanks.
Post Reply