# Equation Gives Unexpected Result

• Jun 29th 2008, 11:54 PM
uniflare
Equation Gives Unexpected Result
Ok im not exactly sure where to post this as i am really bad with math lol(Giggle)

ok to all you geniuses(Nerd)

This Equation Works fine:
0+79*0/(0+1)+293*0/(1+0-(0/62)*62)+479
as it equals 479

This also works fine:
0+79*0/(61+1)+293*(61/1+0-(0/62)*62)+479
as it equals 3352

Unfortunately this gives unexpected results:
479+79*479/(1+1)+293*1/(1+479-(479/62)*62)+479 = 20171.5

20171.5 Should Be: 19884
----
To people who want to know the above equations are actually from a PHP Script. I am trying to convert a JASS script to PHP and im hoping this is the last thing to solve :P.

Thanks for all your help :D
• Jun 30th 2008, 02:04 AM
CaptainBlack
Quote:

Originally Posted by uniflare
Ok im not exactly sure where to post this as i am really bad with math lol(Giggle)

ok to all you geniuses(Nerd)

This Equation Works fine:
0+79*0/(0+1)+293*0/(1+0-(0/62)*62)+479
as it equals 479

This also works fine:
0+79*0/(61+1)+293*(61/1+0-(0/62)*62)+479
as it equals 3352

Unfortunately this gives unexpected results:
479+79*479/(1+1)+293*1/(1+479-(479/62)*62)+479 = 20171.5

20171.5 Should Be: 19884
----
To people who want to know the above equations are actually from a PHP Script. I am trying to convert a JASS script to PHP and im hoping this is the last thing to solve :P.

Thanks for all your help :D

Check your use of brackets and the rules of precedence for PHP. Under the usualy rules your last expression must have a .5 at the end, so your should be cannot be right if the expression is correct.

479 - integer

79*479/(1+1) - is a half integer

293*1/(1+479-(479/62)*62) - integer

479 - is an integer

I would guess 293*1/(1+479-(479/62)*62) is not what is intended

RonL
• Jun 30th 2008, 02:27 AM
uniflare
Thanks
Thank you very much for the suggestion.

The Equation seems to be put off by the scripting language im using.

its called JASS. JASS seems to interpret 479 / 62 * 62 = 343 ??? lol

Strange language.

I have posted on a JASS forum to see if there is a reason....

Thanks again :)
• Jun 30th 2008, 03:01 AM
topsquark
Quote:

Originally Posted by CaptainBlack
293*1/(1+479-(479/62)*62) is a half integer

How is this a half integer?
293*1/(1 + 479 - (479/62)*62)

= 293*1/(1 + 479 - 479)

= 293*1/(1 + 0)

= 293*1/1

= 293

-Dan
• Jun 30th 2008, 03:31 AM
CaptainBlack
Quote:

Originally Posted by topsquark
How is this a half integer?
293*1/(1 + 479 - (479/62)*62)

= 293*1/(1 + 479 - 479)

= 293*1/(1 + 0)

= 293*1/1

= 293

-Dan

Opps... sorry its the one before that:

79*479/(1+1)

That is the half integer!

RonL
• Jun 30th 2008, 03:32 AM
uniflare