Patchwork Use *Q instead of *L floating constants in libquadmath

login
register
mail settings
Submitter Jakub Jelinek
Date Dec. 13, 2012, 12:38 p.m.
Message ID <20121213123838.GQ2315@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/205823/
State New
Headers show

Comments

Jakub Jelinek - Dec. 13, 2012, 12:38 p.m.
Hi!

I've noticed
../../../libquadmath/math/fmaq.c:83:4: warning: floating constant truncated to zero [-Woverflow]
warning and a quick grep revealed a bunch of other bugs, mostly introduced
during the recent ports from newer glibc.

Built on x86_64-linux, committed to trunk.

2012-12-13  Jakub Jelinek  <jakub@redhat.com>

	* math/cbrtq.c (cbrtq): Use Q suffixed floating point constants
	instead of L suffixed ones.
	* math/fmaq.c (fmaq): Likewise.
	* math/rintq.c (TWO112): Likewise.


	Jakub

Patch

--- libquadmath/math/cbrtq.c.jj	2012-11-02 09:01:48.000000000 +0100
+++ libquadmath/math/cbrtq.c	2012-12-13 13:32:26.310751675 +0100
@@ -88,11 +88,11 @@  cbrtq ( __float128 x)
 
   /* Approximate cube root of number between .5 and 1,
      peak relative error = 1.2e-6  */
-  x = ((((1.3584464340920900529734e-1L * x
-	  - 6.3986917220457538402318e-1L) * x
-	 + 1.2875551670318751538055e0L) * x
-	- 1.4897083391357284957891e0L) * x
-       + 1.3304961236013647092521e0L) * x + 3.7568280825958912391243e-1L;
+  x = ((((1.3584464340920900529734e-1Q * x
+	  - 6.3986917220457538402318e-1Q) * x
+	 + 1.2875551670318751538055e0Q) * x
+	- 1.4897083391357284957891e0Q) * x
+       + 1.3304961236013647092521e0Q) * x + 3.7568280825958912391243e-1Q;
 
   /* exponent divided by 3 */
   if (e >= 0)
@@ -122,9 +122,9 @@  cbrtq ( __float128 x)
   x = ldexpq (x, e);
 
   /* Newton iteration */
-  x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333L;
-  x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333L;
-  x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333L;
+  x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333Q;
+  x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333Q;
+  x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333Q;
 
   if (sign < 0)
     x = -x;
--- libquadmath/math/fmaq.c.jj	2012-11-16 12:39:17.000000000 +0100
+++ libquadmath/math/fmaq.c	2012-12-13 13:30:17.999491200 +0100
@@ -80,7 +80,7 @@  fmaq (__float128 x, __float128 y, __floa
 	  < IEEE854_FLOAT128_BIAS - FLT128_MANT_DIG - 2)
 	{
 	  int neg = u.ieee.negative ^ v.ieee.negative;
-	  __float128 tiny = neg ? -0x1p-16494L : 0x1p-16494L;
+	  __float128 tiny = neg ? -0x1p-16494Q : 0x1p-16494Q;
 	  if (w.ieee.exponent >= 3)
 	    return tiny + z;
 	  /* Scaling up, adding TINY and scaling down produces the
@@ -88,7 +88,7 @@  fmaq (__float128 x, __float128 y, __floa
 	     TINY has no effect and in other modes double rounding is
 	     harmless.  But it may not produce required underflow
 	     exceptions.  */
-	  v.value = z * 0x1p114L + tiny;
+	  v.value = z * 0x1p114Q + tiny;
 	  if (TININESS_AFTER_ROUNDING
 	      ? v.ieee.exponent < 115
 	      : (w.ieee.exponent == 0
@@ -100,7 +100,7 @@  fmaq (__float128 x, __float128 y, __floa
 	      volatile __float128 force_underflow = x * y;
 	      (void) force_underflow;
 	    }
-	  return v.value * 0x1p-114L;
+	  return v.value * 0x1p-114Q;
 	}
       if (u.ieee.exponent + v.ieee.exponent
 	  >= 0x7fff + IEEE854_FLOAT128_BIAS - FLT128_MANT_DIG)
@@ -296,7 +296,7 @@  fmaq (__float128 x, __float128 y, __floa
 	    {
 	      w.value = a1 + u.value;
 	      if (w.ieee.exponent == 227)
-		return w.value * 0x1p-226L;
+		return w.value * 0x1p-226Q;
 	    }
 	  /* v.ieee.mant_low & 2 is LSB bit of the result before rounding,
 	     v.ieee.mant_low & 1 is the round bit and j is our sticky
@@ -305,8 +305,8 @@  fmaq (__float128 x, __float128 y, __floa
 	  w.ieee.mant_low = ((v.ieee.mant_low & 3) << 1) | j;
 	  w.ieee.negative = v.ieee.negative;
 	  v.ieee.mant_low &= ~3U;
-	  v.value *= 0x1p-226L;
-	  w.value *= 0x1p-2L;
+	  v.value *= 0x1p-226Q;
+	  w.value *= 0x1p-2Q;
 	  return v.value + w.value;
 	}
       v.ieee.mant_low |= j;
--- libquadmath/math/rintq.c.jj	2012-11-02 09:01:48.000000000 +0100
+++ libquadmath/math/rintq.c	2012-12-13 13:33:09.621501578 +0100
@@ -27,8 +27,8 @@ 
 
 static const __float128
 TWO112[2]={
-  5.19229685853482762853049632922009600E+33L, /* 0x406F000000000000, 0 */
- -5.19229685853482762853049632922009600E+33L  /* 0xC06F000000000000, 0 */
+  5.19229685853482762853049632922009600E+33Q, /* 0x406F000000000000, 0 */
+ -5.19229685853482762853049632922009600E+33Q  /* 0xC06F000000000000, 0 */
 };
 
 __float128