public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pluto at agmk dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/35389] error in norm() of STL
Date: Wed, 27 Feb 2008 20:31:00 -0000 [thread overview]
Message-ID: <20080227203020.528.qmail@sourceware.org> (raw)
In-Reply-To: <bug-35389-15837@http.gcc.gnu.org/bugzilla/>
------- Comment #4 from pluto at agmk dot net 2008-02-27 20:30 -------
Subject: Re: error in norm() of STL
On Wednesday 27 of February 2008 21:13:13 ywei at qualcomm dot com wrote:
> ------- 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
$ ./a.out
(8,1) 64 65
(8,1) 64.999999999999985789 65
(long long)64.99999 -> 64.
------- Comment #5 from pluto at agmk dot net 2008-02-27 20:30 -------
Created an attachment (id=15239)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15239&action=view)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35389
next prev parent reply other threads:[~2008-02-27 20:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-27 10:45 [Bug c++/35389] New: " ywei at qualcomm dot com
2008-02-27 12:44 ` [Bug c++/35389] " rguenth at gcc dot gnu dot org
2008-02-27 12:44 ` rguenth at gcc dot gnu dot org
2008-02-27 20:13 ` ywei at qualcomm dot com
2008-02-27 20:31 ` pluto at agmk dot net [this message]
2008-02-27 20:39 ` pinskia at gcc dot gnu dot org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080227203020.528.qmail@sourceware.org \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).