public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/2181] New: csqrt() sometimes returns negative real
@ 2006-01-19 17:37 wjltemp-temp01 at yahoo dot com
  2006-01-19 18:31 ` [Bug libc/2181] " wjltemp-temp01 at yahoo dot com
  2006-04-23 17:21 ` [Bug math/2181] " drepper at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: wjltemp-temp01 at yahoo dot com @ 2006-01-19 17:37 UTC (permalink / raw)
  To: glibc-bugs

ANSI-C99 7.3.8.3.3 says that the real part of the result csqrt() cannot be
negative. However, when the argument's real part is zero and the imag part is
negative, such as csqrt(0.0-1.0*I), it returns a negative real.  

Looking at the s_csqrt.c (and s_csqrtf.c and s_csqrtl.c)

---------- s_csqrt.c near line 78 ----------

      else if (rcls == FP_ZERO)
    {
      double r = __ieee754_sqrt (0.5 * fabs (__imag__ x));

>>>      __real__ res = __copysign (r, __imag__ x);
>>>      __imag__ res = r;
    }

---------------------------------------------

The two lines marked with >>> appear to be the problem.  When the real part of
the argument is zero, then the real part of the result should be positive and
the imag part of the result should have the same sign as the imag part of the
argument, and both parts of the result should have the same magnitude.  In other
words...

---------- suggested s_csqrt.c near line 78 ----------

      else if (rcls == FP_ZERO)
    {
      double r = __ieee754_sqrt (0.5 * fabs (__imag__ x));

>>>      __real__ res = r;
>>>      __imag__ res = __copysign (r, __imag__ x);
    }

---------------------------------------------

Please test this of course, but I believe this will solve the problem.

Once this is fixed, all the other functions that depend on csqrt() should be
tested. For example, the recently patched cacosh()(bug#2153) will need to be
fixed again.

-Wes Loewer

-- 
           Summary: csqrt() sometimes returns negative real
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: aj at suse dot de
        ReportedBy: wjltemp-temp01 at yahoo dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=2181

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/2181] csqrt() sometimes returns negative real
  2006-01-19 17:37 [Bug libc/2181] New: csqrt() sometimes returns negative real wjltemp-temp01 at yahoo dot com
@ 2006-01-19 18:31 ` wjltemp-temp01 at yahoo dot com
  2006-04-23 17:21 ` [Bug math/2181] " drepper at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: wjltemp-temp01 at yahoo dot com @ 2006-01-19 18:31 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |2182
              nThis|                            |


http://sourceware.org/bugzilla/show_bug.cgi?id=2181

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug math/2181] csqrt() sometimes returns negative real
  2006-01-19 17:37 [Bug libc/2181] New: csqrt() sometimes returns negative real wjltemp-temp01 at yahoo dot com
  2006-01-19 18:31 ` [Bug libc/2181] " wjltemp-temp01 at yahoo dot com
@ 2006-04-23 17:21 ` drepper at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: drepper at redhat dot com @ 2006-04-23 17:21 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2006-04-23 17:20 -------


*** This bug has been marked as a duplicate of 1466 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
          Component|libc                        |math
         Resolution|                            |DUPLICATE


http://sourceware.org/bugzilla/show_bug.cgi?id=2181

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-04-23 17:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-19 17:37 [Bug libc/2181] New: csqrt() sometimes returns negative real wjltemp-temp01 at yahoo dot com
2006-01-19 18:31 ` [Bug libc/2181] " wjltemp-temp01 at yahoo dot com
2006-04-23 17:21 ` [Bug math/2181] " drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).