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?
- X-seq: zsh-workers 43827
- From: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Terminal theme tool – a workaround for lack of 24-bit color in Zsh?
- Date: Thu, 15 Nov 2018 20:50:24 +0900
- In-reply-to: <58111-1540942908.680582@SXAw.BXd_.-x5N>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCEmTTMRR0P3kx9ktpLDBYqJ+MRsE77UMLFjonEZAixfA@mail.gmail.com> <58111-1540942908.680582@SXAw.BXd_.-x5N>
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