This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Use suffixed floating-point constants in float and long double catan/catanh


The catan/catanh functions for float and long double were using
unsuffixed (double) floating-point constants throughout.  In some
cases this may be harmless, but in other cases it may cause undesired
promotions to double and double arithmetic in the float versions.
This patch converts the code to do arithmetic with suffixed constants,
as is usual in libm code.

Tested x86_64 and x86 and committed as obvious.

2013-04-24  Joseph Myers  <joseph@codesourcery.com>

	* math/s_catanf.c (__catanf): Use suffixed floating-point
	constants.
	* math/s_catanhf.c (__catanhf): Likewise.
	* math/s_catanhl.c (__catanhl): Likewise.
	* math/s_catanl.c (__catanl): Likewise.

diff --git a/math/s_catanf.c b/math/s_catanf.c
index 0dc85ff..3ffc6db 100644
--- a/math/s_catanf.c
+++ b/math/s_catanf.c
@@ -67,21 +67,21 @@ __catanf (__complex__ float x)
 
       den = 1 - r2 - __imag__ x * __imag__ x;
 
-      __real__ res = 0.5 * __ieee754_atan2f (2.0 * __real__ x, den);
+      __real__ res = 0.5f * __ieee754_atan2f (2.0f * __real__ x, den);
 
-      num = __imag__ x + 1.0;
+      num = __imag__ x + 1.0f;
       num = r2 + num * num;
 
-      den = __imag__ x - 1.0;
+      den = __imag__ x - 1.0f;
       den = r2 + den * den;
 
       f = num / den;
-      if (f < 0.5)
-	__imag__ res = 0.25 * __ieee754_logf (f);
+      if (f < 0.5f)
+	__imag__ res = 0.25f * __ieee754_logf (f);
       else
 	{
-	  num = 4.0 * __imag__ x;
-	  __imag__ res = 0.25 * __log1pf (num / den);
+	  num = 4.0f * __imag__ x;
+	  __imag__ res = 0.25f * __log1pf (num / den);
 	}
     }
 
diff --git a/math/s_catanhf.c b/math/s_catanhf.c
index ca9a301..9d90a00 100644
--- a/math/s_catanhf.c
+++ b/math/s_catanhf.c
@@ -58,24 +58,24 @@ __catanhf (__complex__ float x)
     {
       float i2 = __imag__ x * __imag__ x;
 
-      float num = 1.0 + __real__ x;
+      float num = 1.0f + __real__ x;
       num = i2 + num * num;
 
-      float den = 1.0 - __real__ x;
+      float den = 1.0f - __real__ x;
       den = i2 + den * den;
 
       float f = num / den;
-      if (f < 0.5)
-	__real__ res = 0.25 * __ieee754_logf (f);
+      if (f < 0.5f)
+	__real__ res = 0.25f * __ieee754_logf (f);
       else
 	{
-	  num = 4.0 * __real__ x;
-	  __real__ res = 0.25 * __log1pf (num / den);
+	  num = 4.0f * __real__ x;
+	  __real__ res = 0.25f * __log1pf (num / den);
 	}
 
       den = 1 - __real__ x * __real__ x - i2;
 
-      __imag__ res = 0.5 * __ieee754_atan2f (2.0 * __imag__ x, den);
+      __imag__ res = 0.5f * __ieee754_atan2f (2.0f * __imag__ x, den);
     }
 
   return res;
diff --git a/math/s_catanhl.c b/math/s_catanhl.c
index 4897c0c..7e2b894 100644
--- a/math/s_catanhl.c
+++ b/math/s_catanhl.c
@@ -58,24 +58,24 @@ __catanhl (__complex__ long double x)
     {
       long double i2 = __imag__ x * __imag__ x;
 
-      long double num = 1.0 + __real__ x;
+      long double num = 1.0L + __real__ x;
       num = i2 + num * num;
 
-      long double den = 1.0 - __real__ x;
+      long double den = 1.0L - __real__ x;
       den = i2 + den * den;
 
       long double f = num / den;
-      if (f < 0.5)
-	__real__ res = 0.25 * __ieee754_logl (f);
+      if (f < 0.5L)
+	__real__ res = 0.25L * __ieee754_logl (f);
       else
 	{
-	  num = 4.0 * __real__ x;
-	  __real__ res = 0.25 * __log1pl (num / den);
+	  num = 4.0L * __real__ x;
+	  __real__ res = 0.25L * __log1pl (num / den);
 	}
 
       den = 1 - __real__ x * __real__ x - i2;
 
-      __imag__ res = 0.5 * __ieee754_atan2l (2.0 * __imag__ x, den);
+      __imag__ res = 0.5L * __ieee754_atan2l (2.0L * __imag__ x, den);
     }
 
   return res;
diff --git a/math/s_catanl.c b/math/s_catanl.c
index e04dba7..67b6b52 100644
--- a/math/s_catanl.c
+++ b/math/s_catanl.c
@@ -67,21 +67,21 @@ __catanl (__complex__ long double x)
 
       den = 1 - r2 - __imag__ x * __imag__ x;
 
-      __real__ res = 0.5 * __ieee754_atan2l (2.0 * __real__ x, den);
+      __real__ res = 0.5L * __ieee754_atan2l (2.0L * __real__ x, den);
 
-      num = __imag__ x + 1.0;
+      num = __imag__ x + 1.0L;
       num = r2 + num * num;
 
-      den = __imag__ x - 1.0;
+      den = __imag__ x - 1.0L;
       den = r2 + den * den;
 
       f = num / den;
-      if (f < 0.5)
-	__imag__ res = 0.25 * __ieee754_logl (f);
+      if (f < 0.5L)
+	__imag__ res = 0.25L * __ieee754_logl (f);
       else
 	{
-	  num = 4.0 * __imag__ x;
-	  __imag__ res = 0.25 * __log1pl (num / den);
+	  num = 4.0L * __imag__ x;
+	  __imag__ res = 0.25L * __log1pl (num / den);
 	}
     }
 

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]