From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id b3829ed5 for ; Fri, 16 Nov 2018 07:55:17 +0000 (UTC) Received: (qmail 1003 invoked by alias); 16 Nov 2018 07:55:00 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43829 Received: (qmail 27717 invoked by uid 1010); 16 Nov 2018 07:55:00 -0000 X-Qmail-Scanner-Diagnostics: from rcpt-expgw.biglobe.ne.jp by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(133.208.98.2):SA:0(-2.6/5.0):. Processed in 2.652928 secs); 16 Nov 2018 07:55:00 -0000 X-Envelope-From: takimoto-j@kba.biglobe.ne.jp X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Biglobe-Sender: From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.1 \(3445.101.1\)) Subject: =?utf-8?Q?Re=3A_Terminal_theme_tool_=E2=80=93_a_workaround_for_la?= =?utf-8?Q?ck_of_24-bit_color_in_Zsh=3F?= Date: Fri, 16 Nov 2018 16:54:51 +0900 References: <58111-1540942908.680582@SXAw.BXd_.-x5N> <1542285877.4637.3.camel@samsung.com> To: zsh-workers@zsh.org In-Reply-To: <1542285877.4637.3.camel@samsung.com> Message-Id: <0B27AD49-061D-4A49-BE6C-85F601AAA067@kba.biglobe.ne.jp> X-Mailer: Apple Mail (2.3445.101.1) X-Biglobe-Spnum: 50585 Is it OK to replace all floats by doubles? What we get is just to silence the (non-standard) warnings. diff --git a/Src/Modules/nearcolor.c b/Src/Modules/nearcolor.c index 0b9877bf4..b49ee9afb 100644 --- a/Src/Modules/nearcolor.c +++ b/Src/Modules/nearcolor.c @@ -33,37 +33,37 @@ #include =20 struct cielab { - float L, a, b; + double L, a, b; }; typedef struct cielab *Cielab; =20 -static float +static double deltae(Cielab lab1, Cielab lab2) { /* taking square root unnecessary as we're just comparing values */ - return powf(lab1->L - lab2->L, 2) + - powf(lab1->a - lab2->a, 2) + - powf(lab1->b - lab2->b, 2); + return pow(lab1->L - lab2->L, 2) + + pow(lab1->a - lab2->a, 2) + + pow(lab1->b - lab2->b, 2); } =20 static void RGBtoLAB(int red, int green, int blue, Cielab lab) { - float R =3D (float)red / 255.0; - float G =3D (float)green / 255.0; - float B =3D (float)blue / 255.0; - R =3D 100.0 * (R > 0.04045 ? powf((R + 0.055) / 1.055, 2.4) : R / = 12.92); - G =3D 100.0 * (G > 0.04045 ? powf((G + 0.055) / 1.055, 2.4) : G / = 12.92); - B =3D 100.0 * (B > 0.04045 ? powf((B + 0.055) / 1.055, 2.4) : B / = 12.92); + double R =3D red / 255.0; + double G =3D green / 255.0; + double B =3D blue / 255.0; + R =3D 100.0 * (R > 0.04045 ? pow((R + 0.055) / 1.055, 2.4) : R / = 12.92); + G =3D 100.0 * (G > 0.04045 ? pow((G + 0.055) / 1.055, 2.4) : G / = 12.92); + B =3D 100.0 * (B > 0.04045 ? pow((B + 0.055) / 1.055, 2.4) : B / = 12.92); =20 /* Observer. =3D 2 degrees, Illuminant =3D D65 */ - float X =3D (R * 0.4124 + G * 0.3576 + B * 0.1805) / 95.047; - float Y =3D (R * 0.2126 + G * 0.7152 + B * 0.0722) / 100.0; - float Z =3D (R * 0.0193 + G * 0.1192 + B * 0.9505) / 108.883; + double X =3D (R * 0.4124 + G * 0.3576 + B * 0.1805) / 95.047; + double Y =3D (R * 0.2126 + G * 0.7152 + B * 0.0722) / 100.0; + double Z =3D (R * 0.0193 + G * 0.1192 + B * 0.9505) / 108.883; =20 - X =3D (X > 0.008856) ? powf(X, 1.0/3.0) : (7.787 * X) + (16.0 / = 116.0); - Y =3D (Y > 0.008856) ? powf(Y, 1.0/3.0) : (7.787 * Y) + (16.0 / = 116.0); - Z =3D (Z > 0.008856) ? powf(Z, 1.0/3.0) : (7.787 * Z) + (16.0 / = 116.0); + X =3D (X > 0.008856) ? pow(X, 1.0/3.0) : (7.787 * X) + (16.0 / = 116.0); + Y =3D (Y > 0.008856) ? pow(Y, 1.0/3.0) : (7.787 * Y) + (16.0 / = 116.0); + Z =3D (Z > 0.008856) ? pow(Z, 1.0/3.0) : (7.787 * Z) + (16.0 / = 116.0); =20 lab->L =3D (116.0 * Y) - 16.0; lab->a =3D 500.0 * (X - Y); @@ -75,7 +75,7 @@ mapRGBto88(int red, int green, int blue) { int component[] =3D { 0, 0x8b, 0xcd, 0xff, 0x2e, 0x5c, 0x8b, 0xa2, = 0xb9, 0xd0, 0xe7 }; struct cielab orig, next; - float nextl, bestl =3D -1; + double nextl, bestl =3D -1; int r, g, b; int comp_r =3D 0, comp_g =3D 0, comp_b =3D 0; =20 @@ -116,7 +116,7 @@ mapRGBto256(int red, int green, int blue) 0xa8, 0xb2, 0xbc, 0xc6, 0xd0, 0xda, 0xe4, 0xee }; struct cielab orig, next; - float nextl, bestl =3D -1; + double nextl, bestl =3D -1; int r, g, b; int comp_r =3D 0, comp_g =3D 0, comp_b =3D 0; =20