From owner-freebsd-standards@FreeBSD.ORG Wed May 7 10:57:44 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 90EA937B416 for ; Wed, 7 May 2003 10:57:42 -0700 (PDT) Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9BE6143F3F for ; Wed, 7 May 2003 10:57:41 -0700 (PDT) (envelope-from sean@perrin.int.nxad.com) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id F263F20F00; Wed, 7 May 2003 10:57:40 -0700 (PDT) Date: Wed, 7 May 2003 10:57:40 -0700 From: Sean Chittenden To: freebsd-standards@FreeBSD.org Message-ID: <20030507175740.GM49916@perrin.int.nxad.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Q0rSlbzrZN6k9QnT" Content-Disposition: inline User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ Subject: float values at the extreme... when did things change? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2003 17:57:44 -0000 --Q0rSlbzrZN6k9QnT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable While PostgreSQL runs its regression tests fine on 4.X, in recent 5.X the return values of floats have changed and I'm trying to figure out the best way to detect this. Under older versions of FreeBSD, the following was true: INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); ERROR: Input '10e400' is out of range for float8 INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); ERROR: Input '-10e400' is out of range for float8 INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); Small values were considered zero. Now, however, small values are out of range: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); ERROR: Input '-10e400' is out of range for float8 INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); ERROR: Input '10e-400' is out of range for float8 INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); ERROR: Input '-10e-400' is out of range for float8 No doubt that things are more correct in their current incarnation, however, when did this change (not sure where to look) and was there a __FreeBSD_version bump regarding this? -sc PS Reason this is on standards is because from what I can tell, -CURRENT's float handling is more standards compliant than previously and figure someone on this list had a hand in making this the case. --=20 Sean Chittenden --Q0rSlbzrZN6k9QnT Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+uUkU3ZnjH7yEs0ERAq9lAKCpvTG1pI06ce9PF7cBGicGdL5evwCfcw86 ux2VPvbGwBVWH8s+OKafQ3E= =orD1 -----END PGP SIGNATURE----- --Q0rSlbzrZN6k9QnT-- From owner-freebsd-standards@FreeBSD.ORG Wed May 7 15:54:53 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2888337B401; Wed, 7 May 2003 15:54:53 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4CAFB43FBD; Wed, 7 May 2003 15:54:49 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3p2/8.8.7) with ESMTP id IAA27366; Thu, 8 May 2003 08:54:45 +1000 Date: Thu, 8 May 2003 08:54:43 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Sean Chittenden In-Reply-To: <20030507175740.GM49916@perrin.int.nxad.com> Message-ID: <20030508080005.D4073@gamplex.bde.org> References: <20030507175740.GM49916@perrin.int.nxad.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: das@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: float values at the extreme... when did things change? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2003 22:54:53 -0000 On Wed, 7 May 2003, Sean Chittenden wrote: > While PostgreSQL runs its regression tests fine on 4.X, in recent 5.X > the return values of floats have changed and I'm trying to figure out > the best way to detect this. > > Under older versions of FreeBSD, the following was true: > > INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); > ERROR: Input '10e400' is out of range for float8 > INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); > ERROR: Input '-10e400' is out of range for float8 > INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); > INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); > > Small values were considered zero. Now, however, small values are out > of range: > > INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); > ERROR: Input '-10e400' is out of range for float8 > INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); > ERROR: Input '10e-400' is out of range for float8 > INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); > ERROR: Input '-10e-400' is out of range for float8 > > No doubt that things are more correct in their current incarnation, > however, when did this change (not sure where to look) and was there a > __FreeBSD_version bump regarding this? -sc > > PS Reason this is on standards is because from what I can tell, > -CURRENT's float handling is more standards compliant than previously > and figure someone on this list had a hand in making this the case. Some LDBL_* constants, especially ones related to small values, were broken in rev.1.7 of the i386 , but this problem seems to be just a bug in the regression tests combined with a change in the implementation-defined behaviour of strtod(). strtod("10e-400", NULL) now sets errno to ERANGE. It apparently now detects underflow when it didn't before, or decides to report this by setting errno to ERANGE when it didn't before. Whether errno is set to ERANGE on underflow is implementation-defined, so it is a bug in the regression tests for them to not expect this error. Whether it is actually an error depends on whether the application cares about underflow. gdtoa has a knob for changing this behaviour (see the README), but this should never be used since it breaks the standard behaviour of setting errno to ERANGE on overflow in strtod(). In RELENG_4, strtod() attempts to set errno to ERANGE on underflow. It has no knob to control this, but its underflow detection is broken unless the library is compiled with -O0. This might be a compiler bug (mishandling of extra precision could easily break underflow checks). Test program: %%% #include #include #include #include int main(void) { double d; errno = 0; d = strtod("10e-400", 0); if (errno != 0) warn("strtod set errno!"); #ifndef TEST_RELENG_4 /* * Can't use this if we #include strtod.c since the current libc * is too different and dumps core. */ printf("%.20g\n", d); #endif return (0); } #ifdef TEST_RELENG_4 /* * Can also link with compat lib to see old behaviour, but that doesn't work * so well for the -O0 case. */ #include "/somewhere/RELENG_4/src/lib/libc/stdlib/strtod.c" #endif %%% Bruce From owner-freebsd-standards@FreeBSD.ORG Wed May 7 16:06:32 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7613737B401; Wed, 7 May 2003 16:06:32 -0700 (PDT) Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id AEB2B43F93; Wed, 7 May 2003 16:06:29 -0700 (PDT) (envelope-from sean@perrin.int.nxad.com) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 3BA8C20F00; Wed, 7 May 2003 16:06:28 -0700 (PDT) Date: Wed, 7 May 2003 16:06:28 -0700 From: Sean Chittenden To: Bruce Evans Message-ID: <20030507230627.GQ49916@perrin.int.nxad.com> References: <20030507175740.GM49916@perrin.int.nxad.com> <20030508080005.D4073@gamplex.bde.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="//IivP0gvsAy3Can" Content-Disposition: inline In-Reply-To: <20030508080005.D4073@gamplex.bde.org> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ cc: das@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: float values at the extreme... when did things change? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2003 23:06:32 -0000 --//IivP0gvsAy3Can Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > > Small values were considered zero. Now, however, small values are out > > of range: > > > > INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); > > ERROR: Input '-10e400' is out of range for float8 > > INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); > > ERROR: Input '10e-400' is out of range for float8 > > INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); > > ERROR: Input '-10e-400' is out of range for float8 > > > > No doubt that things are more correct in their current > > incarnation, however, when did this change (not sure where to > > look) and was there a __FreeBSD_version bump regarding this? -sc >=20 > Some LDBL_* constants, especially ones related to small values, were > broken in rev.1.7 of the i386 , but this problem seems to > be just a bug in the regression tests combined with a change in the > implementation-defined behaviour of strtod(). >=20 > strtod("10e-400", NULL) now sets errno to ERANGE. It apparently now > detects underflow when it didn't before, or decides to report this > by setting errno to ERANGE when it didn't before. Whether errno is > set to ERANGE on underflow is implementation-defined, so it is a bug > in the regression tests for them to not expect this error. Whether > it is actually an error depends on whether the application cares > about underflow. >=20 > gdtoa has a knob for changing this behaviour (see the README), but > this should never be used since it breaks the standard behaviour of > setting errno to ERANGE on overflow in strtod(). >=20 > In RELENG_4, strtod() attempts to set errno to ERANGE on underflow. > It has no knob to control this, but its underflow detection is > broken unless the library is compiled with -O0. This might be a > compiler bug (mishandling of extra precision could easily break > underflow checks). Hrm, considering Peter's recent post regarding gdtoa, can I count on this to continue to work even if gdtoa gets ripped out or isn't in use on a system (isn't gdtoa GPL-ware? Why'd we even bother importing it anyway)? How about the base system's old version of strtod, will it be fixed at some point for higher optimization levels? -sc --=20 Sean Chittenden --//IivP0gvsAy3Can Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+uZFz3ZnjH7yEs0ERAhYTAJwO0FoJop3ZFQ2rCihtxJ1Rq+y8wwCfSECQ kq66ezDG085B72ua6SlX3qU= =da1L -----END PGP SIGNATURE----- --//IivP0gvsAy3Can-- From owner-freebsd-standards@FreeBSD.ORG Wed May 7 16:19:24 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BFCAE37B401; Wed, 7 May 2003 16:19:24 -0700 (PDT) Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3183343FAF; Wed, 7 May 2003 16:19:24 -0700 (PDT) (envelope-from sean@perrin.int.nxad.com) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 8177A2105B; Wed, 7 May 2003 16:19:23 -0700 (PDT) Date: Wed, 7 May 2003 16:19:23 -0700 From: Sean Chittenden To: Bruce Evans Message-ID: <20030507231923.GS49916@perrin.int.nxad.com> References: <20030507175740.GM49916@perrin.int.nxad.com> <20030508080005.D4073@gamplex.bde.org> <20030507230627.GQ49916@perrin.int.nxad.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CXFpZVxO6m2Ol4tQ" Content-Disposition: inline In-Reply-To: <20030507230627.GQ49916@perrin.int.nxad.com> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ cc: das@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: float values at the extreme... when did things change? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2003 23:19:25 -0000 --CXFpZVxO6m2Ol4tQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > Hrm, considering Peter's recent post regarding gdtoa, can I count on > this to continue to work even if gdtoa gets ripped out or isn't in > use on a system (isn't gdtoa GPL-ware? Why'd we even bother > importing it anyway)? How about the base system's old version of > strtod, will it be fixed at some point for higher optimization > levels? -sc Sorry for the follow up. gdtoa isn't GPL-ware, my bad. As Peter pointed out, it's the initials of the author, not GNU. And that said, it looks like gdtoa is here to stay given that it's just the updated version of our older strtod() routines. I'll just use __FreeBSD_version > 500112 as the method for detection. -sc --=20 Sean Chittenden --CXFpZVxO6m2Ol4tQ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+uZR73ZnjH7yEs0ERAp8bAKCUGO+36RaV4FK0QIlkgS3lYZwYWACdErXk 8+d6rVYo56jQjOS2Ectc6Ms= =SVX1 -----END PGP SIGNATURE----- --CXFpZVxO6m2Ol4tQ-- From owner-freebsd-standards@FreeBSD.ORG Wed May 7 20:16:45 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 106EE37B401 for ; Wed, 7 May 2003 20:16:45 -0700 (PDT) Received: from HAL9000.homeunix.com (12-233-57-131.client.attbi.com [12.233.57.131]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4E24E43F85 for ; Wed, 7 May 2003 20:16:44 -0700 (PDT) (envelope-from das@freebsd.org) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.9/8.12.5) with ESMTP id h483GWdN018485; Wed, 7 May 2003 20:16:32 -0700 (PDT) (envelope-from das@freebsd.org) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.9/8.12.5/Submit) id h483GWjL018484; Wed, 7 May 2003 20:16:32 -0700 (PDT) (envelope-from das@freebsd.org) Date: Wed, 7 May 2003 20:16:32 -0700 From: David Schultz To: Sean Chittenden Message-ID: <20030508031632.GA18461@HAL9000.homeunix.com> Mail-Followup-To: Sean Chittenden , Bruce Evans , freebsd-standards@freebsd.org References: <20030507175740.GM49916@perrin.int.nxad.com> <20030508080005.D4073@gamplex.bde.org> <20030507230627.GQ49916@perrin.int.nxad.com> <20030507231923.GS49916@perrin.int.nxad.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030507231923.GS49916@perrin.int.nxad.com> cc: freebsd-standards@freebsd.org Subject: Re: float values at the extreme... when did things change? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 May 2003 03:16:45 -0000 On Wed, May 07, 2003, Sean Chittenden wrote: > Sorry for the follow up. gdtoa isn't GPL-ware, my bad. As Peter > pointed out, it's the initials of the author, not GNU. And that said, > it looks like gdtoa is here to stay given that it's just the updated > version of our older strtod() routines. I'll just use > __FreeBSD_version > 500112 as the method for detection. -sc I don't know why people keep assuming the 'g' stands for GNU. I don't think it stands for the name of the author, either. The original 'dtoa' routine provided IEEE 754 double conversions, whereas 'gdtoa' is a generic routine that operates on many different floating point formats. (The algorithms are basically the same, albeit less efficient.) Thus, the 'g' probably stands for ``generalized''. From owner-freebsd-standards@FreeBSD.ORG Fri May 9 09:04:06 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 17AD637B401 for ; Fri, 9 May 2003 09:04:06 -0700 (PDT) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA6EF43F3F for ; Fri, 9 May 2003 09:04:04 -0700 (PDT) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id C9B03530E; Fri, 9 May 2003 18:04:02 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Sean Chittenden References: <20030507175740.GM49916@perrin.int.nxad.com> <20030508080005.D4073@gamplex.bde.org> <20030507230627.GQ49916@perrin.int.nxad.com> <20030507231923.GS49916@perrin.int.nxad.com> <20030508031632.GA18461@HAL9000.homeunix.com> From: Dag-Erling Smorgrav Date: Fri, 09 May 2003 18:04:02 +0200 In-Reply-To: <20030508031632.GA18461@HAL9000.homeunix.com> (David Schultz's message of "Wed, 7 May 2003 20:16:32 -0700") Message-ID: User-Agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: freebsd-standards@freebsd.org Subject: Re: float values at the extreme... when did things change? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 May 2003 16:04:06 -0000 David Schultz writes: > I don't know why people keep assuming the 'g' stands for GNU. I > don't think it stands for the name of the author, either. The > original 'dtoa' routine provided IEEE 754 double conversions, > whereas 'gdtoa' is a generic routine that operates on many > different floating point formats. (The algorithms are basically > the same, albeit less efficient.) Thus, the 'g' probably stands > for ``generalized''. Both the original dtoa implementation and gdtoa were written by the same author, and he himself describes gdtoa a "generalization of dtoa.c to other IEEE and IEEE-like precisions [...]" DES -- Dag-Erling Smorgrav - des@ofug.org