[cairo] _cairo_color_compute_shorts fails with FPU set to single precision

Carl Worth cworth at cworth.org
Thu Aug 31 04:28:11 PDT 2006


On Thu, 31 Aug 2006 11:08:37 +0000 (GMT), Fabien Costantini wrote:
> >I agree, but wouln't it be better to mult. by 65536 instead of 65536 as follow:
> >if (f <= 0) x = 0; else if (f < 1) x = (int)(f*65536); else x = 65535;
> >because otherwise even values very near from 1.0 (like 1.0- 1.e-9) would be 65534.

Yes, 65536 is the correct multiplier.

> or better :
>      if (f <= 0) x = 0; else if (f < 1-epsilon) x = (int)(f*65536); else x = 65535;
>  to avoid round approx to 65536 when f is very close to 1, epsilon could still be 1.e-5

I greatly prefer the approaches suggested earlier that don't require
an epsilon value at all and simply touch up any 65536 results that
come out of the multiplication.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060831/d4408478/attachment.pgp


More information about the cairo mailing list