This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/43802] New: Tanh Returns Incorrect Value
- From: "tomdean at speakeasy dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Apr 2010 17:32:28 -0000
- Subject: [Bug libstdc++/43802] New: Tanh Returns Incorrect Value
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In c and c++, tanh<complex> returns a different incorrect value.
test-tanh.c: gcc test-tanh.c -o test-tanh-c-lm
test-tanh.cc: g++ test-tanh.cc -o test-tanh-cc
./test-tanh-c 711
libc version 2.10.1
libc release stable
arg = 7.110000e+02 + 7.110000e+02 * i
sinh (arg) = inf + inf * i
cosh (arg) = inf + inf * i
s/c = nan + nan * i (should be 1 + 0 * i)
tanh (arg) = 0.000000e+00 + 0.000000e+00 * i (should be 1 + 0 * i)
./test-tanh-cc 711
libc version 2.10.1
arg (711,711)
sinh(arg) (1.64037e+308,2.55507e+308)
cosh(arg) (1.64037e+308,2.55507e+308)
s/c (1,0)
tanh(arg) (1,4.93127e-618)
==== test-tanh.c ============================
#include <math.h>
#include <complex.h>
#include <stdio.h>
#define _GNU_SOURCE
#include <gnu/libc-version.h>
int main (int argc, char **argv)
{
long double complex arg = 1 + _Complex_I;
long double complex s, c, r, t;
long mult;
if (argc == 2) {
mult = atol(argv[1]);
} else {
mult = 50000L;
}
arg *= mult;
s = csinh (arg);
c = ccosh (arg);
r = s / c;
t = ctanh (arg);
printf ("libc version %s\n", gnu_get_libc_version ());
printf ("libc release %s\n", gnu_get_libc_release ());
printf ("arg = %e + %e * i\n", creal (arg), cimag
(arg));
printf ("sinh (arg) = %e + %e * i\n",
creal (s), cimag (s));
printf ("cosh (arg) = %e + %e * i\n",
creal (c), cimag (c));
printf("s/c = %e + %e * i (should be 1 + 0 * i)\n",
creal (r), cimag (r));
printf ("tanh (arg) = %e + %e * i (should be 1 + 0 * i)\n",
creal (t), cimag (t));
return 0;
}
==== test-tanh.c ============================
#include <iostream>
#include <complex>
#include <gnu/libc-version.h>
#include <stdlib.h> // atol
using namespace std;
int main(int argc, char **argv) {
long mult;
if (argc == 2) {
mult = atol(argv[1]);
} else {
mult = 50000L;
}
complex<long double> arg(1,1);
arg *= mult;
complex<long double> s,c,r,t;
s=sinh(arg);
c=cosh(arg);
r=s/c;
t=tanh(arg);
cout << "libc version " << gnu_get_libc_version() << endl;
cout << "arg " << arg << endl;
cout << "sinh(arg) " << s << endl;
cout << "cosh(arg) " << c << endl;
cout << "s/c " << r << endl;
cout << "tanh(arg) " << t << endl;
return 0;
}
--
Summary: Tanh Returns Incorrect Value
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tomdean at speakeasy dot org
GCC build triplet: Ubuntu 9.10 Distribution
GCC host triplet: ubuntu 9.10
GCC target triplet: i686
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43802