From 8fe89494e6516048759425ec30d8878a6233e00f Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 23 Aug 2013 19:45:38 +0000 Subject: Fix cexp (NaN + i0) (bug 15532). --- math/s_cexp.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'math/s_cexp.c') diff --git a/math/s_cexp.c b/math/s_cexp.c index 655e4e8dee..40e0e518d2 100644 --- a/math/s_cexp.c +++ b/math/s_cexp.c @@ -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; -- cgit 1.4.1