Mail Archives: djgpp/1996/02/15/05:37:52
In article <TANMOY DOT 96Feb1164022 AT qcd DOT lanl DOT gov>,
Tanmoy Bhattacharya <tanmoy AT qcd DOT lanl DOT gov> wrote:
>In article <4eqtu3$ddo AT der DOT twinsun DOT com> eggert AT twinsun DOT com (Paul
>Eggert) writes:
><snip>
> bde AT zeta DOT org DOT au (Bruce Evans) writes:
>
> > a = 1.0;
> > b = FLT_EPSILON / 4.0;
> > c = a + b;
> > assert(c == (float) (a + b));
>
> As far as I can tell the C Standard allows the assertion to either
> succeed or fail, depending on the implementation. The key phrase in
> the standard is ``The values of floating operands and of the results of
> floating expressions may be represented in greater precision and range
> than that required by the type''. So `c' might be represented in more
> bits than `(float) (a + b)' (or vice versa! though this is more
> controversial since it contradicts the Rationale, and it may be
> corrected by the committee soon), and the assertion might fail.
>
>I do not agree with this interpretation, as the footnote (technically,
>not part of the standard) clarifies: an assignment and cast both must
>truncate the result to the required precision...
As must the act of returning a result from a function... according to the
official response to one Defect Report which was filed against the standard.
--
-- Ron Guilmette, Roseville, CA -------- Infinite Monkeys & Co. ------------
---- E-mail: rfg AT monkeys DOT com ----------- Purveyors of Compiler Test Suites -
------ Copyright (c) 1996 by Ronald F. Guilmette; All rights reserved. -----
- Raw text -