C++ complex number tests

Ian Haggard ian@shellus.com
Fri Oct 24 16:15:00 GMT 1997


I was surprised to find out just recently that:
sqrt(complex<double>(-1)) != pow(complex<double>(-1),.5)

It seems the latter, of course, leaves some floating point slop in the
real part of its result.  But when I checked out other Fortran
compilers' implementations of complex, they did the same thing.  Does
anyone know a method to avoid this inconsistency?  I guess it's not
really that important, but it would still be nice.

Anyway, in the course of doing this little investigation, I added a
couple tests to the testsuite for complex numbers, so I thought I'd at
least forward the context diffs to y'all.
-- 
Ian Haggard  ||  ian@shellus.com (work)  ||  IanHaggard@juno.com (home)
GNU/Linux -- "Oh, no, Mr Bill!" || #define employer_opinion !my_opinion


More information about the Gcc-bugs mailing list