[SOLVED ]Maths Glitch?

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
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

[SOLVED ]Maths Glitch?

Post by timWebUK »

Trying to do a bit of maths in PHP and I have run into an issue when using brackets:

Code: Select all

$fltGroundFloorArea = 10;
$beamWidth = 100;

$blockworkArea = $fltGroundFloorArea - ($fltGroundFloorArea * ($beamWidth / 1000));
This produces the result 10. Which isn't correct:

http://www.wolframalpha.com/input/?i=10+-+(10+*+(100/1000))

If anyone could provide any suggestions, that would be great. I've tried rearranging the brackets myself, but always get 10. (Other than the obvious option of doing the equation in two separate sections).
Last edited by timWebUK on Wed Sep 01, 2010 4:49 am, edited 2 times in total.
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: Maths Glitch?

Post by amargharat »

Your script runs correct at my end with result as 9.
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: Maths Glitch?

Post by timWebUK »

I just ran the script too and it shows as 9.

I've realised the mistake is on my part, where my variables (shown in the script) are actually initialised through queries, I had misspelt one of them! ($beamWidth) should be $groundWidthBeam. My mind was blown for a short time, I thought I had broken mathematics.
Post Reply