public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19177] New: Floating-point error with simple subtraction.
@ 2004-12-28 15:29 tob at idlehands dot net
2004-12-28 15:35 ` [Bug c/19177] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: tob at idlehands dot net @ 2004-12-28 15:29 UTC (permalink / raw)
To: gcc-bugs
Here's hoping this doesn't get marked as a duplicate of 323, since the summary contains the keywords
"floating-point" and "error." :)
With the following trivial program, which simply does 20 subtractions, a logic error occurs during a
comparison against the floating point value, believing that o < 0.05 is true when o == 0.05.
This is reproducible on multiple processors. I've tried it with gcc 3.3 on Mac OS X 10.3 (powerppc g4),
as well as gcc 3.3 on Redhat 9.0 (i686) and run into the same result. (For kicks, I did try -ffloat-store,
as suggested in the 323 thread, but this had no effect). The problem occurs at all optimization levels I
tried.
int main()
{
float o = 1.0;
while (1)
{
printf("o: %f\n", o);
if (o < 0.05) break;
o -= 0.05;
}
printf("final o: %f\n", o);
return 0;
}
--
Summary: Floating-point error with simple subtraction.
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tob at idlehands dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19177
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/19177] Floating-point error with simple subtraction.
2004-12-28 15:29 [Bug c/19177] New: Floating-point error with simple subtraction tob at idlehands dot net
@ 2004-12-28 15:35 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-28 15:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-28 15:35 -------
This is your bug, learn how floating point is represented. The point is that .05 is not exactly
representable in floating point.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19177
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-12-28 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-28 15:29 [Bug c/19177] New: Floating-point error with simple subtraction tob at idlehands dot net
2004-12-28 15:35 ` [Bug c/19177] " pinskia at gcc dot gnu dot org
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).