[Bug c++/35389] New: error in norm() of STL
There is something wrong with the norm() in STL to get the norm2 of complex numbers. Suppose we have complex x(8,1), the norm of x should be 8*8 + 1*1 = 65, but norm(x) returns 64, which is incorrect. If we do complex x(8,1), there is no problem, norm(x) does return 65. The issue is not limited to version 4.2.1. It is observed in other versions as well. -- Summary: error in norm() of STL Product: gcc Version: 4.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ywei at qualcomm dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35389
[Bug c++/35389] error in norm() of STL
--- Comment #3 from ywei at qualcomm dot com 2008-02-27 20:13 --- Subject: RE: error in norm() of STL I did additional test based your test code. You are right that norm() seems to be fine. The problem happens when I try to cast the return double value of norm() to unsigned long long (please see my test code below and the corresponding output). Still, it bothers me that if I carry out the norm calculation explicitly, instead of calling norm(), there is no such an issue. Thanks, - Yongbin My test code: = #include #include using namespace std; main() { complex tt(8,1); double x, y; x = norm(tt); double r = tt.real(), i = tt.imag(); y = r*r + i*i; cout << tt << "\t" << (unsigned long long)x << "\t" << (unsigned long long)y << endl; cout << tt << "\t" << x << "\t" << y << endl; } == The output (8,1) 64 65 (8,1) 65 65 -Original Message- From: rguenth at gcc dot gnu dot org [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 27, 2008 4:44 AM To: Wei, Yongbin Subject: [Bug c++/35389] error in norm() of STL --- Comment #2 from rguenth at gcc dot gnu dot org 2008-02-27 12:43 --- I used: #include #include #include int main() { std::complex x(8, 1); std::cout << std::norm(x) << std::endl; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35389
[Bug rtl-optimization/323] optimized code gives strange floating point results
--- Comment #104 from ywei at qualcomm dot com 2008-02-27 21:41 --- Subject: RE: optimized code gives strange floating point results Not sure this is the same issues as 323. All three numbers, 8, 1 and 65, should be able to represented in IEEE 754 floating-point format exactly without any rounding or approximation. That is 8 = 1* 2^3 1 = 1* 2^0 65 = (1 + 1/64) * 2^6 -Original Message- From: pinskia at gcc dot gnu dot org [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 27, 2008 12:39 PM To: Wei, Yongbin Subject: [Bug rtl-optimization/323] optimized code gives strange floating point results --- Comment #103 from pinskia at gcc dot gnu dot org 2008-02-27 20:38 --- *** Bug 35389 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||ywei at qualcomm dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323