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

2020-03-10 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #28 from Jonathan Wakely --- (In reply to kargl from comment #21) > Created attachment 46102 [details] > fix g++ problem with sqrt(z) where z is complex and imag(z) = -0 This one assumes copysign is valid for arguments of type _Tp, w

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

2020-03-10 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #27 from Jonathan Wakely --- Not in stage 4.

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

2020-03-07 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 kargl at gcc dot gnu.org changed: What|Removed |Added CC||kargl at gcc dot gnu.org

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

2019-04-09 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #25 from Steve Kargl --- On Tue, Apr 09, 2019 at 08:24:29PM +, redi at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 > > --- Comment #24 from Jonathan Wakely --- > Thanks for the patch, I'll test it

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

2019-04-09 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #24 from Jonathan Wakely --- Thanks for the patch, I'll test it fully tomorrow. I'll open a separate bug for the FreeBSD issue. We could use more fine-grained configure checks so that most C99 math functions are enabled, even if some

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

2019-04-08 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #23 from kargl at gcc dot gnu.org --- Created attachment 46105 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46105&action=edit fix g++ problem with pow(z,0.5) where imag(z) = -0. This patch has only been tested with the origina

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

2019-04-08 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #22 from Steve Kargl --- On Mon, Apr 08, 2019 at 10:17:00PM +, redi at gcc dot gnu.org wrote: > (In reply to kargl from comment #19) > > I get the expected. So, if you're on a system that has > > _GLIBCXX_USE_C99_COMPLEX, you won

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

2019-04-08 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #21 from kargl at gcc dot gnu.org --- Created attachment 46102 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46102&action=edit fix g++ problem with sqrt(z) where z is complex and imag(z) = -0

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

2019-04-08 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #20 from Jonathan Wakely --- (In reply to Steve Kargl from comment #16) > If Andrew is correct and a builtin is called, Wasn't that me, not Andrew? > you might find > my results if you use -fno-builtins (check spelling). No, same r

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

2019-04-08 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #19 from kargl at gcc dot gnu.org --- (In reply to Steve Kargl from comment #18) > On Mon, Apr 08, 2019 at 08:03:36PM +, pinskia at gcc dot gnu.org wrote: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 > > > > --- Comment

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

2019-04-08 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #18 from Steve Kargl --- On Mon, Apr 08, 2019 at 08:03:36PM +, pinskia at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 > > --- Comment #17 from Andrew Pinski --- > >Doesn't this gets the wrong answ

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

2019-04-08 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #17 from Andrew Pinski --- >Doesn't this gets the wrong answer for __y = -0 (as -0 < 0 is false)? No, you missed this part: // The branch cut is on the negative axis. So maybe the bug is inside FreeBSD and Window

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

2019-04-08 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #16 from Steve Kargl --- On Mon, Apr 08, 2019 at 07:20:22PM +, redi at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 > > --- Comment #13 from Jonathan Wakely --- > (In reply to Steve Kargl from comm

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

2019-04-08 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #15 from Andrew Pinski --- (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.6283607659

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

2019-04-08 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #14 from Jonathan Wakely --- Which is unsurprising because std::sqrt(z) just calls __builtin_csqrt(z.__rep())

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

2019-04-08 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #13 from Jonathan Wakely --- (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,

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

2019-04-08 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #12 from Jonathan Wakely --- (In reply to Steve Kargl from comment #11) > unless [Note: ...] is non-normative text. That's exactly what it is. But we can still aim to meet the intended behaviour.

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

2019-04-08 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #11 from Steve Kargl --- On Mon, Apr 08, 2019 at 02:32:38PM +, sgk at troutmask dot apl.washington.edu wrote: > > I don't have a copy of the C++ standard, so take this specualtion. > pow(z,0.5) is equivalent to sqrt(z). From the

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

2019-04-08 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #10 from Steve Kargl --- On Mon, Apr 08, 2019 at 09:59:22AM +, redi at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 > > --- Comment #7 from Jonathan Wakely --- > I think it's allowed. The standards

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

2019-04-08 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #9 from Jonathan Wakely --- (In reply to Richard Biener from comment #5) > The issue is > > std::pow (__x=..., __y=@0x7fffdcb8: 0.5) > at /home/space/rguenther/install/gcc-9.0/include/c++/9.0.1/complex:1027 > (gdb) l > 1022

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

2019-04-08 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #8 from Andrew Pinski --- Also isn't it true that this is just a different quadrant of the solution? That is the answer is correct but which quadrant being selected is different? That is (a^0.5) actually has two answers where the im

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

2019-04-08 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #7 from Jonathan Wakely --- I think it's allowed. The standards have very little to say about accuracy of any mathematical functions, and complex(0, 0.0) == complex(0, -0.0) is true according to the standard, because +0.0 == -0.0 is t

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

2019-04-08 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #6 from Andrew Pinski --- (In reply to Richard Biener from comment #5) > The issue is > > std::pow (__x=..., __y=@0x7fffdcb8: 0.5) > at /home/space/rguenther/install/gcc-9.0/include/c++/9.0.1/complex:1027 > (gdb) l > 1022

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

2019-04-08 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 Richard Biener changed: What|Removed |Added Keywords||wrong-code --- Comment #5 from Richard

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

2019-04-08 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 Martin Liška changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed|

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

2019-04-05 Thread t.sprodowski at web dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #3 from t.sprodowski at web dot de --- Octave 4.2.2: ans = 2.6284e-20 + 4.2924e-04i

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

2019-04-05 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 kargl at gcc dot gnu.org changed: What|Removed |Added CC||kargl at gcc dot gnu.org --- C

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

2019-04-05 Thread t.sprodowski at web dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 --- Comment #1 from t.sprodowski at web dot de --- Created attachment 46095 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46095&action=edit Source file Source file to illustrate this bug.