Re: Conflicts between C standard and 754-2008
On 2011-01-12 17:19:12 +0000, N.M. Maclaren wrote:
> On Jan 12 2011, Vincent Lefevre wrote:
> >No, you're also using the associativity here, because a+b+c is
> >interpreted unambiguously as (a+b)+c. And from (a+b)+c to (a+c)+b,
> >you're not using the commutativity only, but a succession of
> >commutativity and associativity transformations.
>
> No, that is NOT true, and never has been! Please stop propagating that
> myth. The word that is false (and I mean false) is "unambiguously", and
> without that it is still misleading. All that is unambiguous is the
> PARSING - the evaluation has NEVER been clearly specified.
The evaluation is just a consequence of the parsing. If you follow the
grammar (which specifies expressions), a+b+c is equivalent to (a+b)+c,
and the C standard has no rules concerning explicit parentheses.
> The interpretation of the C standard was drifting towards the parsing
> order being the evaluation order, for different reasons, but WG14 has
> NEVER clarified this point.
Remember that I was answering something related to F.8.2, so that we
are under the context of Annex F (IEEE 754 standard).
> However, C99 really threw the cat among
> the pigeons by introducing FLT_EVAL_METHOD and the FP_CONTRACT pragma.
> In particular, the defaults are implementation-defined, NOT constrained
> by either Annex F or IEEE 754, and permit the use of associativity.
The C standard doesn't specify the accuracy. So, without Annex F or
specification from the implementation, any result is conform to the
standard anyway.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)