octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc-4.2.2 - wrong result of tanh - was (Re: octave-2.9.17 from sourc


From: Rafael Laboissiere
Subject: Re: gcc-4.2.2 - wrong result of tanh - was (Re: octave-2.9.17 from source - make check fails - please help!)
Date: Tue, 13 Nov 2007 15:37:55 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

* juras <address@hidden> [2007-11-13 05:53]:

> It seems again to be an issue in gcc:
> 
> include <complex>
> #include <iostream>
> 
> int main()
> {
>   std::complex<double> x,y,ch,sh,z,z2;
>   x=std::complex<double>(0,M_PI*0.5);
>   y=std::tanh(x);
>   ch=std::cosh(x);
>   sh=std::sinh(x);
>   z=sh/ch;
>   z2=sh; z2/=ch;
>   std::cout<<"x="<<x<<", tanh(x)  = "<<y<<std::endl;
>   std::cout<<"x="<<x<<", sinh(x)  = "<<sh<<std::endl;
>   std::cout<<"x="<<x<<", cosh(x)  = "<<ch<<std::endl;
>   std::cout<<"x="<<x<<", sinh/cosh= "<<z<<std::endl;
>   std::cout<<"x="<<x<<", sh/=ch   = "<<z2<<std::endl;
>   std::cout<<"x="<<x<<", sh/ch2   = "<<(sinh(x)/cosh(x))<<std::endl;
> 
>   return 0;
> }
> 
> gives the result:
> 
> address@hidden:~/download/numerics/test$ make tanh
> g++     tanh.cc   -o tanh
> address@hidden:~/download/numerics/test$ ./tanh
> x=(0,1.5708), tanh(x)  = (nan,inf)
> [snip]

It is not an issue in gcc, but in libc.  This has been already discussed
elsewhere [1].  What version of libc are you using?  This problem has been
fixed over two years ago.

[1] http://www.mail-archive.com/address@hidden/msg91789.html

Cheers,

-- 
Rafael Laboissière


reply via email to

[Prev in Thread] Current Thread [Next in Thread]