# Thread: Equation Gives Unexpected Result

1. ## Equation Gives Unexpected Result

Ok im not exactly sure where to post this as i am really bad with math lol

ok to all you geniuses

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.

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

ok to all you geniuses

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.

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

3. ## 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

4. 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

5. 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