Re: [AD] compare ALLEGRO_COLOR with memcmp

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 6 Jun 2011, at 20:05 , Trent Gamblin wrote:
> The ones in Allegro are safe, because any
> 2 colors created on the same system with al_map* will have the same bit patterns.

In general, you cannot make that assumption. The same sequence of floating point caculations may produce a different outcome the second time they are called. I've seen it happen, but only under specific circumstances in code that is numerically intense. It's also something that is very heavily dependent on compiler vendor, version and settings.
In the particular case of the code in Allegro, I suspect it's probably unlikely because the code is so simple, but if we want to be pedantic, then we should do the comparison allowing for small errors in the float values.

Evert



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/