On Feb 27, 10:19*pm, James Kuyper <jameskuy...@verizon.net> wrote:
> On 02/27/2013 04:48 PM, Eric Sosman wrote:
>
> > On 2/27/2013 3:29 PM, James Kuyper wrote:
> ...
> >> "The accuracy of the floating-point operations (+, -, *, /) and of the
> >> library functions in <math.h> and <complex.h> that return floating-point
> >> results is implementation defined, as is the accuracy of the conversion
> >> between floating-point internal representations and string
> >> representations performed by the library functions in <stdio.h>,
> >> <stdlib.h>, and <wchar.h>. The implementation may state that the
> >> accuracy is unknown." (5.2.4.2.2p6)
>
> > * * *I don't think this paragraph applies. *None of (+, -, *, /)
> > is performed,
>
> I've always assumed that "floating point operations" was the key phrase,
> and *that "(+, -, *, /)" should be taken only as examples,
ditto.
> implying, in
> particular, that the relational and equality operators were also
> intended to be covered by that clause.
surely the implementer would have to be extraordinarily perverse!
Ultimately == comes down to comparing bit patterns. Isn't 0.0 always
going to have the same bit pattern? De-normalised numbers?
Many times I've seen it said that floating point can be used as large
integers. So stuff like this will work
a = 2.0
b = 3.0
a + b == 5.0
> On the other hand, You might be right. If so, does that mean that the
> unary +, unary -, !, ?:, ++, --, and compound assignment operators
> acting on floating point values are also not covered,
unary + and unary - I'd expect "sensible" answers (exluding NaNs, and
numbers with very large magnitudes). Are !, ++ and -- even defined for
FP numbers? What problem do you envisage with ?
and must therefore
> always return exact values? That's trivial to achieve for the first four
> of those operators, but I don't think it's possible for the others - but
> perhaps the others are covered by their definitions in terms of the four
> explicitly-listed operations.
>
> Still,
>
> * * LDBL_MIN + LDBL_EPSILON == LDBL_MAX - LDBL_EPSILON
>
> is unambiguously covered by that clause, and the same is true of
>
> * * nextafterl(LDBL_MIN, 0.0) == nextafterl(LDBL_MAX,0.0)
>
> and having either of those evaluate as true is an equally disconcerting
> possibility.