From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id 6D46F3955416 for ; Tue, 22 Jun 2021 21:25:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D46F3955416 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=keithp.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=keithp.com Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 36EB83F2FD7D; Tue, 22 Jun 2021 14:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1624397148; bh=IK0zq0WNkSXFYLZ1gxrcijZU+tKPK45yApnMII0Uc4M=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=phuK124rX2C9pto5KDNbB0U5G646ggTs+kabiIWKSlTfcHjNPYeyXiJceacv1aVNw Tn1leqKtZ7jn4EAFlgnyDzfHf9XwCMgWg7Iy+fBNXIvf9amjfs3cKwwJgSZ5AL1y09 Nlos7lMVausz0rG1FnXJo3FHQ8U6fz1MxA4T9gfgiDi7rMVpfj6w/c6NOelvJV8Zi1 gIbbvNuIJpJdZv4N96v/NYJZujhmPDstx2wA/LQAxHf6q2F96lF16wtLjoxc/gEa7S gSVEa5qWxs8tQ7woEkiLghMcX+TlbYVXX4Ba3JXGncZy3EqVyEiKlmhyIvbagaTf2s dNirKmruLEcBA== X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id O7Q7slfP_nwj; Tue, 22 Jun 2021 14:25:47 -0700 (PDT) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id D44A73F2EE09; Tue, 22 Jun 2021 14:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1624397147; bh=IK0zq0WNkSXFYLZ1gxrcijZU+tKPK45yApnMII0Uc4M=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=adEPkQEbp+OwlDaGtRRU4Kt1qlzQmLjGczG77mBSE+LsumubUNbdJMwS1ubcFpdot fWNI3sO2mYK1i+wF+CnyHY6lRcIoVBzrl/ReghcI1qtu9Yo2ePGxK1D7BnNTVH8zQ/ d5c6lIlhmpZSyzFgO/3S7+s9qJRHJAZfsCYe7ACrafRymZnTLp/mNrS8Yk3TC7DIhk 5GCx0tUg3ozMz12MITSOoLOOv1mVSozNHpVmAHsoOwT5Akw4hLhB2bf8JloUkf+BD3 ARv0Q7zWYARScq+UUICPJJAjUoYq8tL0orzCeCNBwKXDbzz1ZW1PMVpXfccPPw3bjW 5aSflGbbwsqMA== Received: by keithp.com (Postfix, from userid 1000) id D0BA61E600D2; Tue, 22 Jun 2021 14:25:47 -0700 (PDT) From: Keith Packard To: Joseph Myers Cc: newlib@sourceware.org Subject: Re: [PATCH] stdlib: Make strtod/strtof set ERANGE consistently for underflow. In-Reply-To: References: <878s31pz7i.fsf@keithp.com> Date: Tue, 22 Jun 2021 14:25:47 -0700 Message-ID: <874kdppp5w.fsf@keithp.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP 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, 22 Jun 2021 21:25:51 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Joseph Myers writes: >> This matches glibc behavior, as well as the Linux, Mac OS X, OpenBSD, >> FreeBSD and SunOS strtod man pages. (I should have said 'matches glibc in all of my tests, which are not exhaustive' :-) > What glibc does is set it when the IEEE underflow exception flag is=20 > raised. That is, when the result is tiny and inexact, where "tiny"=20 > follows each architecture's choice of before-rounding or after-rounding=20 > tininess detection (neither of which means "the rounded result is=20 > subnormal"; for both definitions of tiny results, there are values that=20 > round to the least-magnitude normal value of their sign but are still=20 > considered tiny, because after-rounding actually means "the result would= =20 > have a subnormal exponent if rounded to the same precision as for normal= =20 > values but with a wider exponent range"). Thanks for this clarification; I didn't realize that underflow had this additional subtly. It sounds like this means that there are additional cases where errno should be set to ERANGE in the code. I'm afraid I don't understand the workings of this function well enough to know how to detect this particular case. Could we somehow detect this using exceptions? Or are there places in the code which could add some direct checks? =2D-=20 =2Dkeith --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAmDSVVsACgkQ2yIaaQAA ABHKbQ//UcjgyMYtXvldukzHspzRBO0kwm4EBLVH9ews4CJSgXDygMNc8LUQps9m bvAaLXjy3jMhbziP1uKbGw1PCRBKZJwOwOhUacXoC12yfiNN4thUwySRKpYvNtTP 6QQl/40JJE8i1ozl5Poaf9on9I4kmnBYrgzypy7j5HUn/WMxlpxKE+/aXw2+EY0w Q5L4qvj/vKDQAcbcyHAftj68OXeEIUtNJO1CVtZmasRX3mdigsDCV5rnt5Ugrz6F YuYFBwDUIv9MRZEOXigU7bHRu2l3OPgpUJT8jHMzZ8LApJB7XwqrfxgnvQ2SQOkg 27JTbihGmpGVPGIEvDbMvdjRCGzICD5+BTwyXEk86ABpohQV5LlC7lAtcXaeoThY I2pP8fooHv3FiMsUrq54IHo9qLfwIrC+cxe3gRW7eJfY24ggxOhUxE6lCQI9iLiq HAsb/35jpX3n0bAcGQzDOhSVGT9GaJUVQvTFOk9hpSEYBcxjTHu9xSvneJ9csfIF rQOHCAeg9nV2DiogHkoR79zH4CjLudETFH4p9aPTZ4FChyZXVignbGL6oTvsOfz6 egxhkCLwO5w85rdedcNLus/7AgeM1tPKsejKFt0XGTezmGs+kq9iNFz90GD6RIiY EOneDiNqq/KigdBCpOTZlVVZJhUxmXf3Awi7pgicJ2lY275oC8c= =qv3K -----END PGP SIGNATURE----- --=-=-=--