Article View: comp.std.c
Article #1975Re: floating point constant folding
From: Hans van Eck
Date: Wed, 14 Nov 1990 08:58
Date: Wed, 14 Nov 1990 08:58
33 lines
1886 bytes
1886 bytes
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?
>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.
The problem is that the standard (in 3.4) explicitely allows greater range
and precision for floating point expressions when a constant is required,
which seems to take higher precedence than the "as if" rule. What I do not
know is whether this rule may also be applied when a constant is not
required.
Perhaps a simple example is in place:
{ static double d = 0.3F;
double e = 0.3F;
In this example, d may may be initialised with a precision higher than that
of a float. Does that also hold for e?
Thanks in advance.
--
Hans van Eck, Dept. of Mathematics and Computer Science, Vrije Universiteit,
De Boelelaan 1081, 1081 HV Amsterdam, The Netherlands
Voice: +31 20 5485302 Email: eck@cs.vu.nl
Technical Details
Message-ID:
<8237@star.cs.vu.nl>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!star.cs.vu.nl!eckReferences:
<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!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!star.cs.vu.nl!eck From: eck@cs.vu.nl (Hans van Eck) Newsgroups: comp.std.c Subject: Re: floating point constant folding Message-ID: <8237@star.cs.vu.nl> Date: 14 Nov 90 08:58:32 GMT References: <8191@star.cs.vu.nl> <1990Nov13.174025.1520@zoo.toronto.edu> Sender: news@cs.vu.nl Lines: 33