public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: other/3657: Documentation bug re "Problems with floating point computation"
@ 2002-12-05 13:46 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2002-12-05 13:46 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, richard

Synopsis: Documentation bug re "Problems with floating point computation"

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Thu Dec  5 13:46:22 2002
State-Changed-Why:
    Gerald is about to check in a patch for this.
    
    Please accept our apologies for not looking at this report
    for so long -- your report was embarassingly clear :-(

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3657


^ permalink raw reply	[flat|nested] 2+ messages in thread

* other/3657: Documentation bug re "Problems with floating point computation"
@ 2001-07-11 23:26 richard
  0 siblings, 0 replies; 2+ messages in thread
From: richard @ 2001-07-11 23:26 UTC (permalink / raw)
  To: gcc-gnats

>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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-12-05 21:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-05 13:46 other/3657: Documentation bug re "Problems with floating point computation" bangerth
  -- strict thread matches above, loose matches on Subject: below --
2001-07-11 23:26 richard

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).