summaryrefslogtreecommitdiffstats
path: root/lib/msun/src/s_rint.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1996-08-28 16:34:36 +0000
committerbde <bde@FreeBSD.org>1996-08-28 16:34:36 +0000
commitf68534c325392a29ec468b68fad7e222de0b868b (patch)
tree1263974842c58b03868a54b6d0c8d0754e88b3d5 /lib/msun/src/s_rint.c
parentf596cd4a0d4dc86794c1d9ea1142eff8ae4b8093 (diff)
downloadFreeBSD-src-f68534c325392a29ec468b68fad7e222de0b868b.zip
FreeBSD-src-f68534c325392a29ec468b68fad7e222de0b868b.tar.gz
Made rintf() actually work. It was completely broken (when s_rint.c
was compiled with -O) by the precision bug in the i386 version of gcc (assignments and casts don't clip the precision). E.g., rintf(12.3456789) was 12.125. Avoid the same bug in rint(). It was only broken for the unusual case when the i387 precision is 64 bits. FreeBSD defaults to 53 bit precision to avoid problems like this, but the standard math emulator always uses 64 bit precision.
Diffstat (limited to 'lib/msun/src/s_rint.c')
-rw-r--r--lib/msun/src/s_rint.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/msun/src/s_rint.c b/lib/msun/src/s_rint.c
index 3476eef..81a1396 100644
--- a/lib/msun/src/s_rint.c
+++ b/lib/msun/src/s_rint.c
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: s_rint.c,v 1.1.1.1 1994/08/19 09:39:52 jkh Exp $";
+static char rcsid[] = "$Id: s_rint.c,v 1.2 1995/05/30 05:50:18 rgrimes Exp $";
#endif
/*
@@ -27,10 +27,17 @@ static char rcsid[] = "$Id: s_rint.c,v 1.1.1.1 1994/08/19 09:39:52 jkh Exp $";
#include "math.h"
#include "math_private.h"
+/*
+ * TWO23 is long double instead of double to avoid a bug in gcc. Without
+ * this, gcc thinks that TWO23[sx]+x and w-TWO23[sx] already have double
+ * precision and doesn't clip them to double precision when they are
+ * assigned and returned. Use long double even in the !__STDC__ case in
+ * case this is compiled with gcc -traditional.
+ */
#ifdef __STDC__
-static const double
+static const long double
#else
-static double
+static long double
#endif
TWO52[2]={
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
OpenPOWER on IntegriCloud