zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: Terminal theme tool – a workaround for lack of 24-bit color in Zsh?
Date: Thu, 15 Nov 2018 20:50:24 +0900	[thread overview]
Message-ID: <B2AC3BAB-4105-4C49-BE8C-55DA32F94DE7@kba.biglobe.ne.jp> (raw)
In-Reply-To: <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.

  parent reply	other threads:[~2018-11-15 12:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAKc7PVCEmTTMRR0P3kx9ktpLDBYqJ+MRsE77UMLFjonEZAixfA@mail.gmail.com>
2018-10-30 23:41 ` Oliver Kiddle
2018-11-01 18:42   ` dana
2018-11-04  1:42   ` PATCH: true colour support Oliver Kiddle
2018-11-04 22:57     ` Oliver Kiddle
2018-11-05 14:36     ` Sebastian Gniazdowski
     [not found]       ` <46482-1541429525.040210@53iC.Cv7F.M2xE>
2018-11-05 15:48         ` Sebastian Gniazdowski
2018-11-05 16:22           ` Sebastian Gniazdowski
2018-11-06 12:12     ` Sebastian Gniazdowski
2018-11-06 13:37       ` Oliver Kiddle
2018-11-06 21:46         ` Sebastian Gniazdowski
2018-11-06 12:22     ` Should there be a Zsh release for true-color support to adopt earlier? Sebastian Gniazdowski
2018-11-06 22:35       ` Daniel Shahaf
2018-11-06 23:46         ` Bart Schaefer
2018-11-05 14:03   ` Terminal theme tool – a workaround for lack of 24-bit color in Zsh? Sebastian Gniazdowski
2018-11-15 11:50   ` Jun T [this message]
2018-11-15 12:44     ` Peter Stephenson
2018-11-16  7:54       ` Jun T
2018-11-19  8:29         ` Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B2AC3BAB-4105-4C49-BE8C-55DA32F94DE7@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).