View Issue Details

IDProjectCategoryView StatusLast Update
0014869Runner[All Projects] HTML5Public2017-08-03 11:09
ReporterJo-ThijsAssigned ToMike Dailly 
PriorityMediumSeverityC - GeneralReproducibility100%
Status ClosedResolutionWon't Fix 
PlatformHTML5OSWindows 7OS Version
Product Version 
Target VersionFixed in Version 
Summary0014869: HTML5: Intolerant equality check of HTML5
DescriptionWhen creating an empty project, where an object is created and put into a room with the following in its create event:
for(var i = 0; i != 1 && i < 10; i += .1)continue;
show_message(i);

And when the above is tested in both the windows target and the HTML5 target, the result is completely different.
It seems the HTML5 target doesn't deal well with imprecisions, or at least not as well as the windows target

The continue statement is necessary, since I don't do anything in my for loop, but looping through values of i.
The problem is in the looping, it lets i reach 11, while it should stop at 1 and else on 10,
However, comparison of numbers seem a lot more strict in HTML5 target than in windows target.
I've added a gmz file with the problem.
I mainly tested this in internet explorer 11.

http://yoyogames.zendesk.com/attachments/token/kri8MS7ahrHQDgkq4t86TfHzM/?name=HTML_addition_problem.gmz

There seems to be an issue with what 0.1 is when it's added to i. Changed the code to this to see exactly what numbers where being added and you can see why it skips "i != 1".

for (var i = 0; i != 1 && i < 10; i += 0.10) {

show_message(i);
continue;
}
Additional InformationOriginal helpdesk ticket: http://help.yoyogames.com/tickets/61921
1.4 Found In1.3.1344
2.x Runtime Found In
2.x Runtime Verified In2.1.0.124

Activities

GameGeisha

2014-06-18 15:51

Updater   ~0029867

This is not really a bug once you understand that mixing floating-point arithmetic with exact comparisons is never a good combination.

Jo-Thijs

2014-06-18 18:07

Reporter   ~0029891

I know the reason for this issue.
The bug is the fact that the windows target handles comparisons differently.
This causes problems when switching between the two.
The bug is the exact comparison.

xot

2014-06-24 23:45

Updater   ~0030156

Function math_set_epsilon(epsilon) was added to address this sort of thing but it doesn't seem to be implemented in HTML5. If it cannot be, this should be noted in the manual.

Neil Wicker

2014-07-15 15:31

Updater   ~0031110

Last edited: 2014-07-15 15:35

View 2 revisions

Reproduced in 1.99.174 - Assigned. I've also added an updated sample which shows each step of the loop.

As the others say above, it is a bad idea to mix integers and floating point numbers...but the behavior should be consistent between platforms.

Neil Wicker

2014-07-15 15:32

Updater  

HTML_addition_problemUpdate.gmz (904,201 bytes)

Mike Dailly

2017-05-18 11:41

Manager   ~0053207

Will not change. To add this would cause massive slowdown in the JavaScript doe to lots of extra code/calls having to be added in, and will be listed under known platform differences - when I get a proper list together.