View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014869Runner[All Projects] HTML5Public2014-06-18 14:222017-08-03 11:09
Assigned ToMike Dailly 
PriorityMediumSeverityC - GeneralReproducibility100%
StatusClosedResolutionWon't Fix 
PlatformHTML5OSWindows 7OS 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;

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. [^]

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) {

Additional InformationOriginal helpdesk ticket: [^]
1.4 Version1.3.1344
2.x Runtime Version
2.x Runtime Version Verified In2.1.0.124
Attached Files? file icon HTML_addition_problemUpdate.gmz [^] (904,201 bytes) 2014-07-15 15:32

- Relationships

-  Notes
GameGeisha (Updater)
2014-06-18 15:51

This is not really a bug once you understand that mixing floating-point arithmetic with exact comparisons is never a good combination.
Jo-Thijs (Reporter)
2014-06-18 18:07

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 (Updater)
2014-06-24 23:45

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 (Updater)
2014-07-15 15:31
edited on: 2014-07-15 15:35

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.

Mike Dailly (Manager)
2017-05-18 11:41

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.

Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker