having a problem with "greater than"

Just started using Construct 2? Post your questions here

Post » Sat May 16, 2015 1:18 pm

I made an event to subtruct 0.1 from a certian variable as long as this variable is > 0, but every time it reaches 0 it does it another time and then stops (so it reaches -0.1).
can some plaese tell me why this happans?
B
3
Posts: 4
Reputation: 185

Post » Sat May 16, 2015 1:38 pm

It's going to be some other part of your code causing this. Would have to see the code to offer suggestions.
B
13
S
5
G
4
Posts: 139
Reputation: 2,586

Post » Sat May 16, 2015 1:54 pm

ok, how can I paste here an image?
B
3
Posts: 4
Reputation: 185

Post » Sat May 16, 2015 2:07 pm

Many users forget that computer precision is not always what they expect. So for instance, if you are checking for a value to exactly equal another, due to computer float rounding errors, this may never occur.

Without seeing the events it's impossible to say, but ensure that you have taken account of the precision errors that may occur - i.e. don't check for an exact value if possible.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,564
Reputation: 60,472

Post » Sat May 16, 2015 2:13 pm

so ins't any way to fix it?
"http:" //s1068.photobucket.com/user/dvir45014501/media/problem%20with%20gt_zps79fbnvja.png.html
Last edited by Dvir on Sat May 16, 2015 2:17 pm, edited 1 time in total.
B
3
Posts: 4
Reputation: 185

Post » Sat May 16, 2015 2:16 pm

Would need to see what you've done. Generally, use such things as INT, FLOOR, ROUND, CEILING etc to ensure that fractional parts don't come into it.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,564
Reputation: 60,472

Post » Sat May 16, 2015 2:19 pm

ok thanks
B
3
Posts: 4
Reputation: 185


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest