% Operator bug work around

Discussion and feedback on Construct 2

Post » Tue Oct 16, 2012 2:49 pm

So apparently there is this bug in javascript..

Modulo values don't work properly with negative numbers:

-2%10 equals -2
when it should equal 8

A simple work around is described on this site
[QUOTE]
So instead of -5%4 which gives the wrong answer in JavaScript we substitute ((-5%4)+4)%4
[/QUOTE]

Not really a big deal but thought I should bring this to attention.. It'd be useful to implement if it's not too much hassle.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Tue Oct 16, 2012 5:23 pm

I found this bug, and switched to using a bunch of ifs to handle the negative cases. Ill have to try your formula.
B
15
S
5
G
2
Posts: 357
Reputation: 3,691


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests