K
Keith Thompson
CBFalconer said:Keith said:[...]CBFalconer said:Keith Thompson wrote:
... snip ...
And if I write this:
double x = 1.0;
if (x < 1.0) puts("Oops!");
if (x > 1.0) puts("Oops!");
do I have any grounds for complaint if the program prints
"Oops!"? If the stored value represents a range, I would
think the answer would be no.
x is a double. So is the expression (1.0). So they represent
the same range.
I think you're saying that the above code may not print "Oops!",
but you didn't actually say so. Can you confirm that?
As written, yes. With the modification I wrote, no.
In the following, I will ignore NaNs and infinities.
So in your model, (x < y) must yield 0 if both x and y represent
the same range, even though some values in the range of x are less
than some values in the range of y. Presumably (x < y) yields 1 if
and only if each value in the range of x is less than each value
in the range of y. And (x == y) if and only if both ranges are
exactly the same. Is that correct?
No. If x and y contain the identical ranges, there are no values
in the x range outside the y range, and vice-versa. So your
statement is impossible. The only thing that controls the ranges
is the value in x (or y). The actual size of the ranges is FP
system dependant.
I believe you have misunderstood what I wrote.
Let's suppose that, in accordance with your model, the stored double
value 1.0 represents the range of real numbers 1.0-EPS .. 1.0+EPS
assuming for simplicity that the range is symmetric). Then given:
double x = 1.0;
double y = 1.0;
both x and y represent identical ranges. Each of these identical
ranges contains infinitely many real numbers. Some of the numbers
within x's range are less that some of the numbers within y's range;
for example, 1.0-EPS (which is in x's range) is less than 1.0+EPS
(which is in y's range). Nevertheless, in your model, (x < y) must
yield 0.
And just what do you mean by "the value in x (or y)"? Are you
implying that x has just a single value?
Incidentally, in my article there were 5 paragraphs following what you
quoted, full of questions directed to you in an attempt to understand
your conception of C's floating-point model. You have snipped those
paragraphs without so much as a "[...]". My assumption is that you
were unable to answer my questions because your floating-point model
is actually inconsistent. Either that or you didn't bother to read
them.