Division math bug with "half-width of", "half-height of" blocks

out2lunch

• Posts: 118
This is for Jon and the gang.

With the "half-width of Self" and "half-height of Self" blocks, Stencyl pastes in actor.getWidth()/2 and actor.getHeight()/2 into the code, but doesn't put parenthesis around them.  Most cases are ok except when used with another division where operator precedence gives the wrong answer.  Here's some examples:

(5 * 5) / 2 = 12.5   (Precedence will force this to happen, luckily equalling the intended one)
5 * (5 / 2) = 12.5   (Intended precedence)

(5 / 5) / 2 = 0.5   (Precedence groups them left to right, so this is the answer given instead of the intended one)
5 / (5 / 2) = 2.0   (Intended precedence)

5 + (5 / 2) = 7.5   (Precedence will force this to match the intended one)
5 + (5 / 2) = 7.5   (Intended precedence)

5 - (5 / 2) = 2.5   (Precedence will force this to match the intended one)
5 - (5 / 2) = 2.5   (Intended precedence)

Operator precedence: http://haxe.org/manual/operators

So, can Stencyl put parenthesis around them? ex: (actor.getWidth()/2)
Clacky Train has been released worldwide on the App Store!
Voodoo Zombie's 1.4.1 update has more bosses and magic items on the App Store!
Here's the Launch Trailer on YouTube.

Jon

• Posts: 17524
Thanks, this is now fixed in the nightlies.