]> sourceware.org Git - newlib-cygwin.git/commitdiff
* mingwex/complex/csqrt.c (csqrt): The sign of real part
authorDanny Smith <dannysmith@users.sourceforge.net>
Wed, 12 Oct 2005 06:46:18 +0000 (06:46 +0000)
committerDanny Smith <dannysmith@users.sourceforge.net>
Wed, 12 Oct 2005 06:46:18 +0000 (06:46 +0000)
of result is positive when real part of arg == 0;
* mingwex/complex/csqrtf.c (csqrtf): Ditto.
* mingwex/complex/csqrtl.c (csqrtl): Ditto.

winsup/mingw/ChangeLog
winsup/mingw/mingwex/complex/csqrt.c
winsup/mingw/mingwex/complex/csqrtf.c
winsup/mingw/mingwex/complex/csqrtl.c

index 2cdd5c4d298e9fd666d0c39e786813b276f8abd4..896c5b1d0b9f26042d0a0041b07cf75931796990 100644 (file)
@@ -1,3 +1,10 @@
+2005-10-12  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       * mingwex/complex/csqrt.c (csqrt): The sign of real part
+       of result is positive when real part of arg == 0;
+       * mingwex/complex/csqrtf.c (csqrtf): Ditto.
+       * mingwex/complex/csqrtl.c (csqrtl): Ditto.
+
 2005-10-12  Danny Smith  <dannysmith@users.sourceforge.net>
 
        * include/time.h (_time64): Correct prototype.
index 3717939f40e670bba0a8b027a51b11771cfb813d..b5f8868e94f11741d55a6f9629d3c3b6aa772c2c 100644 (file)
@@ -31,22 +31,23 @@ double complex  csqrt (double complex Z)
   else if (x == 0.0)
     {
       t = sqrt(0.5 * fabs (y));
-      __real__ Res = y > 0 ? t : -t;
-      __imag__ Res = t;
+      __real__ Res = t;
+      __imag__ Res = y > 0 ? t : -t;
     }
 
   else
     {
       t = sqrt (2.0  * (_hypot (x, y) + fabs (x)));
+      double u = t / 2.0;
       if ( x > 0.0)
         {      
-          __real__ Res = 0.5 * t;
+          __real__ Res = u;
           __imag__ Res = y / t;
         }
       else
         {
          __real__ Res = fabs ( y / t);
-         __imag__ Res = (y < 0.0 ? -0.5 : 0.5) * t;
+         __imag__ Res = y < 0.0 ? -u : u;
         }
     }
 
index b39cbb468956df334f04555f8b02c273e3e20c86..7c37e99ce6d1d014c51ad17ddc565fe039ec98d6 100755 (executable)
@@ -25,8 +25,8 @@ float complex  csqrtf (float complex Z)
   else if (x == 0.0f)
     {
       r = sqrtf(0.5f * fabsf (y));
-      __real__ Res = y > 0 ? r : -r;
-      __imag__ Res = r;
+      __real__ Res = r;
+      __imag__ Res = y > 0 ? r : -r;
     }
 
   else
index f058b216a0ce42d999c6a266abdac1fd2563022b..1b2ebbe5be2198a1b21b6f69fa6bc24cf1350818 100755 (executable)
@@ -31,8 +31,8 @@ long double complex  csqrtl (long double complex Z)
   else if (x == 0.0L)
     {
       r = sqrtl(0.5L * fabsl (y));
-      __real__ Res = y > 0 ? r : -r;
-      __imag__ Res = r;
+      __real__ Res = r;
+      __imag__ Res = y > 0 ? r : -r;
     }
 
   else
This page took 0.037312 seconds and 5 git commands to generate.