summary refs log tree commit diff
path: root/misc/qefgcvt.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-28 22:39:04 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-28 22:39:04 +0000
commitb113c12c350c29a0f7f06fba12f06d86e79de1f4 (patch)
treeb42569c0a1afb8ea9358239ceecb64834c6c038d /misc/qefgcvt.c
parentaa847ee5a48c4dc582960b1ee575a82cab005a01 (diff)
downloadglibc-b113c12c350c29a0f7f06fba12f06d86e79de1f4.tar.gz
glibc-b113c12c350c29a0f7f06fba12f06d86e79de1f4.tar.xz
glibc-b113c12c350c29a0f7f06fba12f06d86e79de1f4.zip
Update.
1999-07-28  Ulrich Drepper  <drepper@cygnus.com>

	* misc/efgcvt.c: Use IEEE 854 formula to compute the number of digits
	to print.
	* misc/efgcvt_r.c: Likewise.
	* misc/qefgcvt.c: Likewise.
	* misc/qefgcvt_r.c: Likewise.
	* misc/tst-efgcvt.c: Remove one test which cannot reliably be run
	anymore.
Diffstat (limited to 'misc/qefgcvt.c')
-rw-r--r--misc/qefgcvt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c
index af65fc1688..faf788aa5d 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -17,13 +17,20 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <float.h>
+
 #define FLOAT_TYPE long double
 #define FUNC_PREFIX q
 #define FLOAT_FMT_FLAG "L"
 /* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but
    we don't have log10 available in the preprocessor.  Since we cannot
    assume anything on the used `long double' format be generous.  */
-#define MAXDIG (LDBL_DIG + 12)
-#define NDIGIT_MAX LDBL_DIG
+#define MAXDIG (NDIGIT_MAX + 12)
+#if LDBL_MANT_DIG == 64
+# define NDIGIT_MAX 21
+#else
+/* See IEEE 854 5.6, table 2 for this formula.  */
+# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
+#endif
 
 #include "efgcvt.c"