delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/31/18:36:22

Xref: news2.mv.net comp.lang.c:54543 comp.lang.c++:70040 comp.os.msdos.djgpp:685 gnu.g++.help:4441 gnu.gcc.help:5654
From: larry DOT jones AT sdrc DOT com (Larry Jones)
Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
Subject: Re: float != float and floats as return types
Date: 31 Jan 1996 18:25:23 GMT
Organization: SDRC Engineering Services
Lines: 33
Distribution: world
Message-ID: <4eoc6j$8vi@info1.sdrc.com>
References: <4ej9lb$mpc AT fu-berlin DOT de> <310D4D9C DOT 7DAB2E1B AT alcyone DOT com> <310DF403 DOT 2EDA7BBD AT alcyone DOT com>
NNTP-Posting-Host: thor.sdrc.com
Originator: scjones AT thor
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <310DF403 DOT 2EDA7BBD AT alcyone DOT com>, Erik Max Francis <max AT alcyone DOT com> writes:
> Russell Blackadar wrote:
> 
> > What is surprising is that all the columns are not zero!  The original poster
> > was offering some speculations as to how that might have happened, but as you
> > say (and I think he'd agree) it doesn't wash.  I ran his posted code and
> > got all zeroes.  Either there's a *serious* problem with his compiler, or the
> > posted code is not the same as what he compiled.
> 
> Not at all.  Systematic errors are expected when using floating point
> computations.
> 
> Under gcc 2.6.3 for Linux, his program prints the following:

Making gcc an ANSI/ISO Standard conforming compiler is trickier than it
seems -- the required options are neither simple nor obvious.  This is
particularly true in places like floating point arithmetic where people
are generally less concerned with getting the exactly ``correct''
results (i.e., what the standard says you should get) than they are
with getting reasonably correct results fast.

In particular, the standard generally allows a compiler to compute
floating point results with more precision than it requires, but there
are a number of places where it requires any excess precision to be
removed.  gcc generally does not remove the excess precision in those
cases.  Specifying -ffloat-store helps; on i386/i486 machines so does
-mno-fp-ret-in-387; but, as far as I can tell, there is no way (as of
gcc 2.7.1) to make gcc conform completely on i386/i486 machines as there
is no way to force it to remove precision as a result of a cast.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry DOT jones AT sdrc DOT com
I like maxims that don't encourage behavior modification. -- Calvin

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019