public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: richard@wetafx.co.nz To: gcc-gnats@gcc.gnu.org Subject: other/3657: Documentation bug re "Problems with floating point computation" Date: Wed, 11 Jul 2001 23:26:00 -0000 [thread overview] Message-ID: <20010712061601.16909.qmail@sourceware.cygnus.com> (raw) >Number: 3657 >Category: other >Synopsis: Documentation bug re "Problems with floating point computation" >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: doc-bug >Submitter-Id: net >Arrival-Date: Wed Jul 11 23:26:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Richard Addison-Wood >Release: n/a >Organization: >Environment: n/a >Description: This web page: http://www.gnu.org/software/gcc/bugs.html shows this example code fragment: double min = 0.0; double max = 0.5; double width = 0.01; std::cout << (int)(((max - min) / width) - 1) << std::endl; and asserts that it "might print 50 on some systems and optimization levels, and 51 on others." I assert that it is only reasonable that this code would be expected to print 49 or 48. I know this is a bit picky, since the main point of the example is to show that finite representation of real numbers has limitations and to be aware of rounding issues. However, it is easy to correct the comment. >How-To-Repeat: Compile and run the example on a few systems and at different optimization levels. The results should be 49 or 48. >Fix: Revise the example code or the comment about what the result should be. It may also be useful to show, for this trivial example, how to revise it to be more reliable. For example: (int)(((max - min) / width) - 0.5 >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2001-07-11 23:26 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-07-11 23:26 richard [this message] 2002-12-05 13:46 bangerth
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=20010712061601.16909.qmail@sourceware.cygnus.com \ --to=richard@wetafx.co.nz \ --cc=gcc-gnats@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).