------- 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 <iostream> #include <complex> using namespace std; main() { complex<double> 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 <complex> #include <algorithm> #include <iostream> int main() { std::complex<double> x(8, 1); std::cout << std::norm(x) << std::endl; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35389