🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1980

Re: floating point constant folding

#1980
From: Donald Lewine
Date: Wed, 14 Nov 1990 14:34
34 lines
2264 bytes
In article <1990Nov13.174025.1520@zoo.toronto.edu>, henry@zoo.toronto.edu (Henry Spencer) writes:
|> In article <8191@star.cs.vu.nl> eck@cs.vu.nl (Hans van Eck) writes:
|> >Is it allowed to evaluate constant floating point expressions with greater
|> >range and precision than that of the execution environment in contexts
|> >where a constant is not required?
|> >
|> >There are unexpected implications of both allowing and disallowing such
|> >folding, but I cannot find a statement in the standard that unambiguously
|> >says what a translator may or may not do.
|> 
|> I believe the relevant statement is the "as if" rule discussed in 2.1.2.3:
|> the compiler can do anything it pleases, provided the observable results
|> are the same.  Observable results include overflow exceptions and the values
|> of data items written out to files.  Evaluating constant floating-point
|> expressions at compile time using different floating-point hardware strikes
|> me as a minefield of difficulties.

See section 3.1.3 of the rationale: "In folding and converting
constants, an implementation must use at least as much precision as
is provided by the target environment.  However, it is not required
to used exactly the precision as the target, since this would require
a cross compiler to simulate target arithmetic at translation time."
 
In other words, the "as if" rule does not require getting a
bit-for-bit identical result. The "minefield of difficulties" can
be safely crossed.

--------------------------------------------------------------------
Donald A. Lewine                (508) 870-9008 Voice
Data General Corporation        (508) 366-0750 FAX
4400 Computer Drive. MS D112A
Westboro, MA 01580  U.S.A.

uucp: uunet!dg!lewine   Internet: lewine@cheshirecat.webo.dg.com
Technical Details
Message-ID: <1142@dg.dg.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!dg!cheshirecat!lewine
References: <8191@star.cs.vu.nl> <1990Nov13.174025.1520@zoo.toronto.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!dg!cheshirecat!lewine
From: lewine@cheshirecat.rtp.dg.com (Donald Lewine)
Newsgroups: comp.std.c
Subject: Re: floating point constant folding
Message-ID: <1142@dg.dg.com>
Date: 14 Nov 90 14:34:03 GMT
References: <8191@star.cs.vu.nl> <1990Nov13.174025.1520@zoo.toronto.edu>
Sender: root@dg.dg.com
Reply-To: uunet!dg!lewine
Organization: Data General Corporation
Lines: 34