GNOME Bugzilla – Bug 598664
Comparing floats with == is not safe
Last modified: 2009-12-09 23:56:25 UTC
In worm.c gnibbles_worm_get_tail_direction there is a lot of float comparing with == going on. http://git.gnome.org/cgit/gnome-games/tree/gnibbles/worm.c#n238
I have a few comments about the commit. Now I am no expert on floats but isn't the value you compare the absolute difference to supposed to be a very small non-zero number? Like 0.00001 or whatever is appropriate? http://git.gnome.org/cgit/gnome-games/commit/?id=271ad87eabe1f3f346b294f78b1fbf85c0c567d7
Sorry for the late reply, I hadn't CC'ed myself to the bug.. You are right, I'm no expert either and it look like I had the wrong information at that time. So, after looking at proper documentation [1], I made the fix and I'll commit it later. Hopefully, it should be THE safe way to compare float :) [1] http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm
Fixed by Guillaume in: http://git.gnome.org/cgit/gnome-games/commit/?id=377e7fcafa8e654a236f6b820094179a32bd5513 Thanks