From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 4E02B3947413 for ; Tue, 10 Mar 2020 14:47:20 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583851640; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=vGGkXeUbjLeXK/IQlnxtgALS07Qxs9VF8ceONsWScVc=; b=JY7qbh038puTlfGQL7vyfeOEQi84L6Gc66LugBcVauN6fmW1DPHtse45kADzeA+oAldme9 lO/2pAyTJhZ11DeLD3nNpTGuaFhbjwaW5ePjt6IUT0WT3jFcmy+XEp1XGob17kv9+C2kBw iti6xc9jyWuCZGeqMPp1I4wDjGjuMXs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-lJBttOpkM-SEvnMDY0RJZA-1; Tue, 10 Mar 2020 10:47:17 -0400 X-MC-Unique: lJBttOpkM-SEvnMDY0RJZA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC1A0DB61; Tue, 10 Mar 2020 14:47:16 +0000 (UTC) Received: from calimero.vinschen.de (ovpn-116-30.ams2.redhat.com [10.36.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 860BD7389F; Tue, 10 Mar 2020 14:47:16 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id E72F9A827D9; Tue, 10 Mar 2020 15:47:14 +0100 (CET) Date: Tue, 10 Mar 2020 15:47:14 +0100 From: Corinna Vinschen To: Fabian Schriever Cc: newlib@sourceware.org Subject: Re: [PATCH] Fix error in fdim/f for infinities Message-ID: <20200310144714.GV4042@calimero.vinschen.de> Reply-To: newlib@sourceware.org Mail-Followup-To: Fabian Schriever , newlib@sourceware.org References: <20200310102412.391-1-fabian.schriever@gtd-gmbh.de> MIME-Version: 1.0 In-Reply-To: <20200310102412.391-1-fabian.schriever@gtd-gmbh.de> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sCNd3Ivk/oijKKf1" Content-Disposition: inline X-Spam-Status: No, score=-27.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2020 14:47:21 -0000 --sCNd3Ivk/oijKKf1 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mar 10 11:24, Fabian Schriever wrote: > The comparison c =3D=3D FP_INFINITE causes the function to return +inf as= it > expects x =3D +inf to always be larger than y. This shortcut causes > several issues as it also returns +inf for the following cases: > - fdim(+inf, +inf), expected (as per C99): +0.0 > - fdim(-inf, any non NaN), expected: +0.0 >=20 > I don't see a reason to keep the comparison as all the infinity cases > return the correct result using just the ternary operation. > --- > newlib/libm/common/s_fdim.c | 5 +---- > newlib/libm/common/sf_fdim.c | 5 +---- > 2 files changed, 2 insertions(+), 8 deletions(-) >=20 > diff --git a/newlib/libm/common/s_fdim.c b/newlib/libm/common/s_fdim.c > index 73a027953..61a4908f3 100644 > --- a/newlib/libm/common/s_fdim.c > +++ b/newlib/libm/common/s_fdim.c > @@ -49,11 +49,8 @@ ANSI C, POSIX. > =09double y; > #endif > { > - int c =3D __fpclassifyd(x); > - if (c =3D=3D FP_NAN) return(x); > + if (__fpclassifyd(x) =3D=3D FP_NAN) return(x); > if (__fpclassifyd(y) =3D=3D FP_NAN) return(y); > - if (c =3D=3D FP_INFINITE) > - return HUGE_VAL; > =20 > return x > y ? x - y : 0.0; > } > diff --git a/newlib/libm/common/sf_fdim.c b/newlib/libm/common/sf_fdim.c > index fe349098b..8fee57002 100644 > --- a/newlib/libm/common/sf_fdim.c > +++ b/newlib/libm/common/sf_fdim.c > @@ -14,11 +14,8 @@ > =09float y; > #endif > { > - int c =3D __fpclassifyf(x); > - if (c =3D=3D FP_NAN) return(x); > + if (__fpclassifyf(x) =3D=3D FP_NAN) return(x); > if (__fpclassifyf(y) =3D=3D FP_NAN) return(y); > - if (c =3D=3D FP_INFINITE) > - return HUGE_VALF; > =20 > return x > y ? x - y : 0.0; > } > --=20 > 2.24.1.windows.2 >=20 Pushed. Thanks, Corinna --=20 Corinna Vinschen Cygwin Maintainer Red Hat --sCNd3Ivk/oijKKf1 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl5nqHIACgkQ9TYGna5E T6Ch0A/8DnZZQUBwAo5tLVOYDZVAvzNJuwLX50nVOUnuEkrmnrKK5HOuExYPkVJ1 bQ0tYL7j+JVTA4a9H8/BVOaXT/7i+X/vwRuOLe3dW7TWHVook+YyLbO2sqmWNyi3 GhV8pDs499YMXlXFMhwN/oEILoMWSia5oXwM5pwschtD8LN6WMy8KNe1A4pmAyO0 eCXjVAJOZuWxdIp257SXenk9+N43poNliXTDXXPuWihWPjJDRfE0aja6YmcC73S6 5OGgZuln0oB7uuHNYg31CYMsgc6CDmW30jpGJThmBLuYbvG2MyIhYeRaGoN+78/F 3+eqFUKP5SJXBkHUw81KBhr2OoicEr3d593twP4RBHtkHnrYYZsdj0n5CLFM9Kwz roa/+nYiEkhqOYzFoTTJQQNsnpIsxaBWGWdctb2F+dhBio5eiGnYVIkNmPkwdFcM gFSQBsE5Quf91J4PYNYlNvOkgo7u5DNhVjre0Dz/JJo9LKsdBlxrg9dXm4H+Zekw ysgl+LwCULvkVGNQzgvQ5/4De6FiQFdfAAMbUKTJlDxAp1UI8jnC8KzJ+g9j5bwp So9wPwVjVhsl9nRvLkc4xVmqK+vBnGP6poiN77mVowAfWjh/yspqDSVWbAI5baim ywnhvypJa6hWUUUJlmnPUX0HbpWhPSoqx2OsRkL/KGPfa7C9UHw= =CeXd -----END PGP SIGNATURE----- --sCNd3Ivk/oijKKf1--