C
crisgoogle
[email protected] said:CBFalconer <[email protected]> wrote:<big snip><more snip>Everyone understands that for the vast majority of mathematical
results
that one "tries" to store in a float, that result is not exactly
representable.You seem to believe that the float therefore represents all those
possible values.By your reasoning, an unsigned int also represents an infinite
number of values, namely: x + n * (UINT_MAX + 1), where n is in
Z, and x of course is the single value, on [0, UINT_MAX], that
most people would say is stored in that unsigned int.Is that your claim, that, without looking at the programming,
unsigned ints have an infinite number of values? If not, why not?
How is this situation different than that for floats?
No, because the arithmetic system on unsigned ints is closed.
Apart from division by zero, you can't generate a value outside the
set 0 .. UINT_MAX. Those things are not integers. They follow
defined rules. They are not intended to represent integers.
Similarly floats are not reals, and also follow defined rules.
However we can always deposit a real in a float, and the question
is 'what is that real'.
Right, the floats follow defined rules, and under those rules,
they _are_ closed. Operations on floats
result in floats. As someone else (Keith T?) mentioned elsthread,
any real value that might, theoretically, be the mathematical
result of any float operation _never_ exists in the computer.
The operands are floats, the FPU stores them and the results
in floating point registers, and the value stored back to
memory is a float.
I still don't see what the fundamental difference in approaches is.
Sure, unsigned int's are not integers. But neither are floats reals.
Values stored back into either one are not necessarily the
mathematical result of the expression that led to that value.
Either one may be the result of literally an infinite number
of mathematical values.