[Bug libstdc++/89991] Complex numbers: Calculation of imaginary part is not correct

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Apr 8 19:42:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991

--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #13)
> (In reply to Steve Kargl from comment #10)
> > %  g++8 -o z  a.cpp -lm && ./z
> >             z = (-1.84250315177824e-07,-0)
> >    pow(z,0.5) = (2.62836076598358e-20,-0.000429243887758258)
> >       sqrt(z) = (0,0.000429243887758258)
> > sqrt(conj(z)) = (0,0.000429243887758258)
> > conj(sqrt(z)) = (0,-0.000429243887758258)
> > 
> > This looks wrong.
> 
> I can't reproduce this, I get:
> 
>             z = (-1.84250315177824e-07,-0)
>    pow(z,0.5) = (2.62836076598358e-20,-0.000429243887758258)
>       sqrt(z) = (0,-0.000429243887758258)
> sqrt(conj(z)) = (0,0.000429243887758258)
> conj(sqrt(z)) = (0,0.000429243887758258)

My bet now comes to the fact there have been improvements to glibc which
changed the behavior here ....  

Also I used the wrong term, it is the branch cut that is the issue.  Most of
the branch cuts were fixed in glibc in 2012; though there might have been some
fixed later on.


More information about the Gcc-bugs mailing list