Page 1 of 1

[SOLVED ]Maths Glitch?

Posted: Wed Sep 01, 2010 4:37 am
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).

Re: Maths Glitch?

Posted: Wed Sep 01, 2010 4:44 am
by amargharat
Your script runs correct at my end with result as 9.

Re: Maths Glitch?

Posted: Wed Sep 01, 2010 4:48 am
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.