Print this page
11175 libm should use signbit() correctly
11188 c99 math macros should return strictly backward compatible values

@@ -71,21 +71,23 @@
         PIo2    =  1.570796326794896619231321691639751442099L,
         PI      =  3.141592653589793238462643383279502884197L,
         PI_lo   =  8.671810130123781024797044026043351968762e-35L;
 
 long double
-atan2l(long double y, long double x) {
+atan2l(long double y, long double x)
+{
         long double t, z;
         int k, m, signy, signx;
 
         if (x != x || y != y)
                 return (x + y); /* return NaN if x or y is NAN */
         signy = signbitl(y);
         signx = signbitl(x);
         if (x == one)
                 return (atanl(y));
-        m = signy + signx + signx;
+        /* Ensure sign indicators are boolean */
+        m = (signy != 0) + (signx != 0) + (signx != 0);
 
         /* when y = 0 */
         if (y == zero)
                 switch (m) {
                 case 0:

@@ -98,11 +100,11 @@
                         return (-PI - tiny);    /* atan(-0,-anything) */
                 }
 
         /* when x = 0 */
         if (x == zero)
-                return (signy == 1 ? -PIo2 - tiny : PIo2 + tiny);
+                return (signy != 0 ? -PIo2 - tiny : PIo2 + tiny);
 
         /* when x is INF */
         if (!finitel(x)) {
                 if (!finitel(y)) {
                         switch (m) {

@@ -128,11 +130,11 @@
                         }
                 }
         }
         /* when y is INF */
         if (!finitel(y))
-                return (signy == 1 ? -PIo2 - tiny : PIo2 + tiny);
+                return (signy != 0 ? -PIo2 - tiny : PIo2 + tiny);
 
         /* compute y/x */
         x = fabsl(x);
         y = fabsl(y);
         t = PI_lo;

@@ -154,7 +156,7 @@
                 return (PI - (z - t));  /* atan(+,-) */
         case 3:
                 return ((z - t) - PI);  /* atan(-,-) */
         }
         /* NOTREACHED */
-    return 0.0L;
+        return (0.0L);
 }