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?



On Thu, 2018-11-15 at 20:50 +0900, Jun T wrote:
> 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 majority of standardish Unixy systems I know about are designed to
assume most floating point calculations are going to be done as double
--- I see Linux supplies float and long double versions of library
functions as a supplement.  But I doubt Oliver was thinking that much
about optimisation here --- terminal IO is slow enough I can't see how
it could be a big deal.

pws



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