More ANSI float.h stuff
Mike McNally
m5 at lynx.uucp
Thu Jan 19 02:39:51 AEST 1989
The <float.h> file of the ANSI library contains two constants, FLT_EPSILON
and DBL_EPSILON. These are (according to K&R II) supposed to be the
smallest x such that 1.0 + x != 1.0. Should I interpret this as:
The smallest x such that the statement
i = (1.0 + x != 1.0);
assigns 1 to the variable i.
or should it be:
The smallest x such that the sequence:
val1 = 1.0;
val2 = 1.0 + x;
i = val1 != val2;
results in assignment of 1 to the variable i.
Seems to me that there is a difference, because intermediate results during
expression evaluation may involve greater precision than available for
storage of values.
On a related note, the qualification that x be the "smallest" value bothers
me: shouldn't x be positive? Most likely the actual ANSI draft is more
specific; it probably clears up the first question as well.
--
Mike McNally Lynx Real-Time Systems
uucp: {voder,athsys}!lynx!m5 phone: 408 370 2233
Where equal mind and contest equal, go.
More information about the Comp.lang.c
mailing list