This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/2153] New: cacosh() not ANSI-C99 complient
- From: "wjltemp-temp01 at yahoo dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 14 Jan 2006 15:02:10 -0000
- Subject: [Bug libc/2153] New: cacosh() not ANSI-C99 complient
- Reply-to: sourceware-bugzilla at sourceware dot org
glibc-2.3.6
The cacosh() function does not always give correct ANSI-C99 complient results.
When the real part of the argument is negative, the result is the negative of
what it should be.
For example, the result of cacosh(-0.3 + 0.4*I) should be 0.405112 + 1.851426*I,
but instead, the result comes out -0.405112 + -1.851426*I.
While this is one of the many inverse hyperbolic cosines, it's not THE inverse
hyperbolic cosine specified by ANSI-C99 7.3.6.1.3, which states that the real
part of the result must be non-negative. ("The cacosh functions return the
complex arc hyperbolic cosine value, in the range of a half-strip of
non-negative values along the real axis and in the interval [-i*pi, +i*pi] along
the imaginary axis.")
This can be easily fixed by adding either of the following in s_cacosh.c (and
related s_cacoshf.c and s_cacoshl.c):
--------- original s_cacosh.c, line 67 ----------
else
{
__complex__ double y;
__real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0;
__imag__ y = 2.0 * __real__ x * __imag__ x;
y = __csqrt (y);
__real__ y += __real__ x;
__imag__ y += __imag__ x;
res = __clog (y);
}
--------- proposed s_cacosh.c ----------
else
{
__complex__ double y;
__real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0;
__imag__ y = 2.0 * __real__ x * __imag__ x;
y = __csqrt (y);
>>> if (__real__ x < 0.0)
>>> y = -y;
__real__ y += __real__ x;
__imag__ y += __imag__ x;
res = __clog (y);
}
--------- or another proposed s_cacosh.c ----------
else
{
__complex__ double y;
__real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0;
__imag__ y = 2.0 * __real__ x * __imag__ x;
y = __csqrt (y);
__real__ y += __real__ x;
__imag__ y += __imag__ x;
res = __clog (y);
>>> if (__real__ x < 0.0)
>>> res = -res;
}
-----------------------------------------
Thank you,
-Wes Loewer
--
Summary: cacosh() not ANSI-C99 complient
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: wjltemp-temp01 at yahoo dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=2153
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.