about summary refs log tree commit diff
path: root/misc/efgcvt_r.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-11-04 23:45:45 +0000
committerUlrich Drepper <drepper@redhat.com>1998-11-04 23:45:45 +0000
commitff8ac38322d991429a64dd127173af99dee3d9ca (patch)
tree857c258a5ae7292290a9ebb8fefb531a21d9d169 /misc/efgcvt_r.c
parent00c1176b65cc2961b094c3dd78dd53072eb61fe9 (diff)
downloadglibc-ff8ac38322d991429a64dd127173af99dee3d9ca.tar.gz
glibc-ff8ac38322d991429a64dd127173af99dee3d9ca.tar.xz
glibc-ff8ac38322d991429a64dd127173af99dee3d9ca.zip
Update.
1998-11-04  Ulrich Drepper  <drepper@cygnus.com>

	* misc/efgcvt_r.c (fcvt_r): Remove code which tries to use libm
	functions.  Reduce error in computing normalized value by multiplying
	factor in loop and compute result in one step.
Diffstat (limited to 'misc/efgcvt_r.c')
-rw-r--r--misc/efgcvt_r.c60
1 files changed, 22 insertions, 38 deletions
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
index 64dcfcd7e9..1c237eed4a 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -136,10 +136,6 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
   return 0;
 }
 
-#define weak_extern2(name) weak_extern (name)
-weak_extern2 (FLOOR) weak_extern2 (LOG10) weak_extern2 (FABS)
-weak_extern2 (EXP)
-
 int
 APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
      FLOAT_TYPE value;
@@ -151,46 +147,34 @@ APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
 
   if (isfinite (value) && value != 0.0)
     {
-      FLOAT_TYPE (*log10_function) (FLOAT_TYPE) = &LOG10;
-
-      if (log10_function)
-	{
-	  /* Use the reasonable code if -lm is included.  */
-	  FLOAT_TYPE dexponent;
-	  dexponent = FLOOR (LOG10 (FABS (value)));
-	  value *= EXP (dexponent * -M_LN10);
-	  exponent = (int) dexponent;
-	}
+      /* Slow code that doesn't require -lm functions.  */
+      FLOAT_TYPE d;
+      FLOAT_TYPE f = 1.0;
+      if (value < 0.0)
+	d = -value;
       else
+	d = value;
+      if (d < 1.0)
 	{
-	  /* Slow code that doesn't require -lm functions.  */
-	  FLOAT_TYPE d;
-	  if (value < 0.0)
-	    d = -value;
-	  else
-	    d = value;
-	  if (d < 1.0)
+	  do
 	    {
-	      do
-		{
-		  d *= 10.0;
-		  --exponent;
-		}
-	      while (d < 1.0);
+	      f *= 10.0;
+	      --exponent;
 	    }
-	  else if (d >= 10.0)
+	  while (d * f < 1.0);
+
+	  value *= f;
+	}
+      else if (d >= 10.0)
+	{
+	  do
 	    {
-	      do
-		{
-		  d *= 0.1;
-		  ++exponent;
-		}
-	      while (d >= 10.0);
+	      f *= 10;
+	      ++exponent;
 	    }
-	  if (value < 0.0)
-	    value = -d;
-	  else
-	    value = d;
+	  while (d >= f * 10.0);
+
+	  value /= f;
 	}
     }
   else if (value == 0.0)