This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/25017] New: sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: "harald dot vogt at desy dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Nov 2005 12:00:28 -0000
- Subject: [Bug libfortran/25017] New: sqrt, csqrt may give a wrong result if real part of compex argument is zero
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Seen on intel architectures (i686, x86_64). Run following example code:
program test
complex cres1, cres2, ivc
parameter(ivc = (0,1))
const= 0
fact = 0.5
cres1 = csqrt(const + ivc*fact)
cres2 = csqrt(const - ivc*fact)
print*,'cres1=',cres1, 'cres2=',cres2
const= 1.e-30
cres1 = csqrt(const + ivc*fact)
cres2 = csqrt(const - ivc*fact)
print*,'cres1=',cres1, 'cres2=',cres2
stop
end
The result is:
cres1= ( 0.5000000 , 0.5000000 ) cres2= (-0.5000000 , 0.5000000 )
cres1= ( 0.5000000 , 0.5000000 ) cres2= ( 0.5000000 ,-0.5000000 )
The first line shows the wrong result, the second is that what one expects.
The compiler used it taken from gcc SVN. gfortran -v gives:
gcc version 4.1.0 20051118 (experimental)
--
Summary: sqrt, csqrt may give a wrong result if real part of
compex argument is zero
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: harald dot vogt at desy dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25017
- Follow-Ups:
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: fxcoudert at gcc dot gnu dot org
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: jvdelisle at verizon dot net
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: pinskia at gcc dot gnu dot org
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: kargl at gcc dot gnu dot org
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: pinskia at gcc dot gnu dot org
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: sgk at troutmask dot apl dot washington dot edu
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: harald dot vogt at desy dot de
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: sgk at troutmask dot apl dot washington dot edu
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: harald dot vogt at desy dot de
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: sgk at troutmask dot apl dot washington dot edu
- [Bug libfortran/25017] sqrt, csqrt may give a wrong result if real part of compex argument is zero
- From: sgk at troutmask dot apl dot washington dot edu