public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hobiger at nict dot go dot jp" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/31179] New: strange behaviour of floor rounding Date: Thu, 15 Mar 2007 01:45:00 -0000 [thread overview] Message-ID: <bug-31179-14247@http.gcc.gnu.org/bugzilla/> (raw) This following small program will show the problem # report.cpp #include <cmath> #include <iostream> int main(int argc, char* argv[]) { double A=140.70; double x=floor((A*100)); std::cout << "Testing: A = " << A << " --> A*100 = " << A*100 << " but floor(A*100) = " << x << "\n"; double B=140.60; double y=floor((B*100)); std::cout << "Testing: B = " << B << " --> B*100 = " << B*100 << " but floor(B*100) = " << y << "\n"; } The program was compiled simply by "g++ report.cpp -o report." For all machines available here I obtained Testing: A = 140.7 --> A*100 = 14070 but floor(A*100) = 14069 Testing: B = 140.6 --> B*100 = 14060 but floor(B*100) = 14060 The latter result is as expected but for A=128.7,129.7,130.7....163.7 floor rounding gives wrong results. This bug has been verified on several architectures (PIII,P3, WinXP - Cygwin) and under several versions of gcc/g++ (4.1.1 - on FC6, 4.0.2 - on RH, 3.4.6 -on RH) Any ideas where this comes frome ??? -- Summary: strange behaviour of floor rounding Product: gcc Version: unknown Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hobiger at nict dot go dot jp http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31179
next reply other threads:[~2007-03-15 1:45 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-03-15 1:45 hobiger at nict dot go dot jp [this message] 2007-03-15 5:37 ` [Bug middle-end/31179] " 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=bug-31179-14247@http.gcc.gnu.org/bugzilla/ \ --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: linkBe 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).