]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix cexp (NaN + i0) (bug 15532).
authorJoseph Myers <joseph@codesourcery.com>
Fri, 23 Aug 2013 19:45:38 +0000 (19:45 +0000)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 15 Nov 2013 17:03:55 +0000 (11:03 -0600)
ChangeLog
math/libm-test.inc
math/s_cexp.c
math/s_cexpf.c
math/s_cexpl.c

index 346f69933b766d170dc17ce93b5fcad8fb16bc1d..649b282e1c496d41bb2080012c919c952df2bb51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-08-23  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #15532]
+       * math/s_cexp.c (__cexp): Return NaN + i0 for NaN + i0 argument.
+       * math/s_cexpf.c (__cexpf): Likewise.
+       * math/s_cexpl.c (__cexpl): Likewise.
+       * math/libm-test.inc (cexp_test_data): Correct expected return
+       value for NaN + i0.  Add another test.
+
 2013-08-21  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #15797]
index 8c1dcac8e8a92afe00d7e92081849e1b4958b609..7408c6b312ecbd8f2891ad53ea238554f1c5deb8 100644 (file)
@@ -6193,7 +6193,8 @@ static const struct test_c_c_data cexp_test_data[] =
 
     TEST_c_c (cexp, plus_infty, qnan_value, plus_infty, qnan_value),
 
-    TEST_c_c (cexp, qnan_value, 0.0, qnan_value, qnan_value, INVALID_EXCEPTION_OK),
+    TEST_c_c (cexp, qnan_value, 0.0, qnan_value, 0.0),
+    TEST_c_c (cexp, qnan_value, minus_zero, qnan_value, minus_zero),
     TEST_c_c (cexp, qnan_value, 1.0, qnan_value, qnan_value, INVALID_EXCEPTION_OK),
 
     TEST_c_c (cexp, qnan_value, plus_infty, qnan_value, qnan_value, INVALID_EXCEPTION_OK),
index 655e4e8deebca91450f982281cab3b70683e2d88..40e0e518d2ac40dca769c82621a5cbe2f35e1d10 100644 (file)
@@ -145,12 +145,18 @@ __cexp (__complex__ double x)
     }
   else
     {
-      /* If the real part is NaN the result is NaN + iNaN.  */
+      /* If the real part is NaN the result is NaN + iNaN unless the
+        imaginary part is zero.  */
       __real__ retval = __nan ("");
-      __imag__ retval = __nan ("");
+      if (icls == FP_ZERO)
+       __imag__ retval = __imag__ x;
+      else
+       {
+         __imag__ retval = __nan ("");
 
-      if (rcls != FP_NAN || icls != FP_NAN)
-       feraiseexcept (FE_INVALID);
+         if (rcls != FP_NAN || icls != FP_NAN)
+           feraiseexcept (FE_INVALID);
+       }
     }
 
   return retval;
index fa942d34f79526a3fc5fb29896d468ae3d52ea17..7c422051644e4d91afbc1a2b9e65bbb9796d2379 100644 (file)
@@ -145,12 +145,18 @@ __cexpf (__complex__ float x)
     }
   else
     {
-      /* If the real part is NaN the result is NaN + iNaN.  */
+      /* If the real part is NaN the result is NaN + iNaN unless the
+        imaginary part is zero.  */
       __real__ retval = __nanf ("");
-      __imag__ retval = __nanf ("");
+      if (icls == FP_ZERO)
+       __imag__ retval = __imag__ x;
+      else
+       {
+         __imag__ retval = __nanf ("");
 
-      if (rcls != FP_NAN || icls != FP_NAN)
-       feraiseexcept (FE_INVALID);
+         if (rcls != FP_NAN || icls != FP_NAN)
+           feraiseexcept (FE_INVALID);
+       }
     }
 
   return retval;
index d827bc3de41a70a544704b2564ecc6b2bacf3838..0c356033666f3f415c136a04eb6a1ba8753658c3 100644 (file)
@@ -145,12 +145,18 @@ __cexpl (__complex__ long double x)
     }
   else
     {
-      /* If the real part is NaN the result is NaN + iNaN.  */
+      /* If the real part is NaN the result is NaN + iNaN unless the
+        imaginary part is zero.  */
       __real__ retval = __nanl ("");
-      __imag__ retval = __nanl ("");
+      if (icls == FP_ZERO)
+       __imag__ retval = __imag__ x;
+      else
+       {
+         __imag__ retval = __nanl ("");
 
-      if (rcls != FP_NAN || icls != FP_NAN)
-       feraiseexcept (FE_INVALID);
+         if (rcls != FP_NAN || icls != FP_NAN)
+           feraiseexcept (FE_INVALID);
+       }
     }
 
   return retval;