Re: [AD] Small bugfix in hsv_to_rgb() and smaller fix in rgb_to_hsv()

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


> I agree about the floats, but the code for making sure the cast from float
> to int truncates instead of rounds should be changed, and also, the patch
> tidies up a few things, like remembering to put an 'f' at the end of
> float-constants and adding some casts that weren't there before.

Sorry, I wasn't clear enough: the +0.5f fix for 'v' is ok, I was only talking 
about the comparison against 0.0f at the beginning of the function.

As for the missing 'f's:

-      h = fmod(h, 360.0) / 60.0;
-      if (h < 0)
+      h = fmod(h, 360.0f) / 60.0f;
+      if (h < 0.0f)
 	 h += 6.0f;

Note that fmod() takes and returns 'double' so 360.0 and 60.0 are not that 
bad. But I'll change them anyway.

As for the explicit casts, I think they gratuitously overload the code.

-- 
Eric Botcazou




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