[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#36876: marked as done ([PR c/6900] Floating point behaviour of gcc on pentium)



Your message dated Fri, 27 Dec 2002 14:40:31 +0100
with message-id <15884.22607.564215.137435@gargle.gargle.HOWL>
and subject line Bug#36876: c/6900: Floating point behaviour of gcc on pentium
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 29 Apr 1999 07:33:34 +0000
Received: (qmail 14254 invoked from network); 29 Apr 1999 07:33:17 -0000
Received: from imsc.ernet.in (202.41.95.1)
  by master.debian.org with SMTP; 29 Apr 1999 07:33:17 -0000
Received: from aspc30.imsc.ernet.in (shyam@aspc30 [202.41.95.160])
	by imsc.ernet.in (8.9.1/8.9.1) with ESMTP id NAA17992;
	Thu, 29 Apr 1999 13:02:05 +0530 (IST)
From: Ghanashyam Date <shyam@imsc.ernet.in>
Received: (from shyam@localhost)
	by aspc30.imsc.ernet.in (8.8.8/8.8.8/Debian/GNU) id NAA00877;
	Thu, 29 Apr 1999 13:04:16 +0530
Message-Id: <199904290734.NAA00877@aspc30.imsc.ernet.in>
Subject: Erratic behaviour of gcc/egcc on pentium
To: submit@bugs.debian.org
Date: Thu, 29 Apr 1999 13:04:16 +0530 (IST)
Cc: sure@imsc.ernet.in
X-Mailer: ELM [version 2.4ME+ PL39 (25)]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

The following program gives erratic/correct answers under different
conditions. The program is self explanatory.

The expected behaviour is to get the value of the variable 'q' to equal the
value of the variable 'shift' . Erratic behaviour refers to deviation from
this equality. The deviation can be controlled by increasing/decreasing the
value of 'factor' . The variable take GENERIC values.

The expected behaviour is seen on SGI and SPARC machines with their native
compilers and also with gcc (2.7x), with or without optimization.

On pentium with gcc/egcs the following happens:

Without optimization:	only those x which are powers of 2 give q = shift.
With optimization:	all give q = shift.

The deviations are NOT an artifact of printf formats. If subsequents
iterations are done with further code, these deviations actually get
amplified, and thus are genuine. In a non trivial code, this uncontrolled
error accumulation is a disaster.

While it is true that beyond 15 decimal places, one has garbage bits in the
internal representation, a suitable round-off/truncation etc should discard
these bits correctly and consistantly for generic values. (Other platforms
mentioned above seem to take care of this so also optimization on pentium
platform.)

In another context, with a somewhat different program, the expected behaviour
resulted WITH-OUT optimization but WITH optimization, the behaviour was
erratic.

Details of versions etc:
------------------------

$ uname -a ;
Linux aspc30 2.0.36 #1 Mon Mar 29 12:46:14 IST 1999 i586 unknown

$ egcc -v ;
Reading specs from /usr/lib/gcc-lib/i486-linux/egcs-2.90.29/specs
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)

$ gcc -v ;
Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.2.3/specs
gcc version 2.7.2.3

$ ld -v ;
GNU ld version 2.9.1 (with BFD 2.9.1)

$ ldd /usr/bin/gcc
	/lib/nfslock.so.0 => /lib/nfslock.so.0 (0x4000d000)
	libc.so.6 => /lib/libc.so.6 (0x40013000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

$ ldd /usr/bin/egcc
	/lib/nfslock.so.0 => /lib/nfslock.so.0 (0x4000d000)
	libc.so.6 => /lib/libc.so.6 (0x40013000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

--------------------------------------------------------
PLEASE ADVISE.
	-G. Date (shyam@imsc.ernet.in)
--------------------------------------------------------

/*---------------------------------------------------------------------*/
# include <stdio.h>

main(argc, argv)
int argc;
char **argv ;

{
	double q, q0, x, factor, shift;

	factor = 100000000.000001L ; 	/* Choose any typical fraction */
	shift = 0.0L ;

	for(x = 0.0L; x < 257.0L; x = x + 1.0L )	{
		q0 = (factor)*x ;
		q =  q0 - factor*x + shift ;
		if( q == shift )
			printf(" TRUE:\t%20.8E%20.8E%20.8E\n", x, q0, q);
		else		
			printf("FALSE:\t%20.8E%20.8E%20.8E\n", x, q0, q);
	}
}

/*---------------------------------------------------------------------*/
---------------------------------------
Received: (at 36876-done) by bugs.debian.org; 27 Dec 2002 13:42:50 +0000
>From doko@cs.tu-berlin.de Fri Dec 27 07:42:50 2002
Return-path: <doko@cs.tu-berlin.de>
Received: from mail.cs.tu-berlin.de [130.149.17.13] (root)
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 18RulF-0005gi-00; Fri, 27 Dec 2002 07:42:49 -0600
Received: from bolero.cs.tu-berlin.de (daemon@bolero.cs.tu-berlin.de [130.149.19.1])
	by mail.cs.tu-berlin.de (8.9.3/8.9.3) with ESMTP id OAA12761
	for <36876-done@bugs.debian.org>; Fri, 27 Dec 2002 14:40:31 +0100 (MET)
Received: (from doko@localhost)
	by bolero.cs.tu-berlin.de (8.11.6+Sun/8.9.3) id gBRDeVc19127;
	Fri, 27 Dec 2002 14:40:31 +0100 (MET)
From: Matthias Klose <doko@cs.tu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <15884.22607.564215.137435@gargle.gargle.HOWL>
Date: Fri, 27 Dec 2002 14:40:31 +0100
To: 36876-done@bugs.debian.org
Subject: Re: Bug#36876: c/6900: Floating point behaviour of gcc on pentium
In-Reply-To: <[🔎] 20021204145145.21694.qmail@thales.mathematik.uni-ulm.de>
References: <[🔎] 20021204145145.21694.qmail@thales.mathematik.uni-ulm.de>
X-Mailer: VM 7.03 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid
Delivered-To: 36876-done@bugs.debian.org
X-Spam-Status: No, hits=-8.9 required=5.0
	tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_01_02
	version=2.41
X-Spam-Level: 

closing the Debian report as well.

Christian Ehrhardt writes:
> 
> Hi,
> 
> This is not a bug. Comparing floating point numbers with == may yield
> unexpected results due to rounding errors. Someone please close this PR.
> 
>    regards  Christian
> 
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6900



Reply to: