Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Terminal theme tool – a workaround for lack of 24-bit color in Zsh?



In nearcolor.c, function RGBtoLAB(), floating point data are saved in
float (not double) variables; for example:

> +     float R = (float)red / 255.0;
(snip)
> +     R = 100.0 * (R > 0.04045 ? powf((R + 0.055) / 1.055, 2.4) : R / 12.92);

Is this to improve performance?
If so, it would be better to explicitly use float literals, such as 255.0f.
Otherwise, since 255.0 is double, all the calculations are done in double
(after promoting all values to double), and the final result is truncated
back to float.

I believe there is virtually no performance difference (on most CPUs).
The reason I'm writing this is I'm getting lots of warnings like:

nearcolor.c:55:18: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    R = 100.0 * (R > 0.04045 ? powf((R + 0.055) / 1.055, 2.4) : R / 12.92);
                 ^ ~

-Wdouble-promotion is OFF by default, but I still want to remove these
warnings.


Messages sorted by: Reverse Date, Date, Thread, Author