[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bounded, infinite ranges?



Stavros Macrakis writes:

-----------------------------------------------------------
The elements of the range should be in general calculated as from+I*by
rather than as ((from+by)+by)+by+...  This also guarantees that you
don't get killed by round-off.  On the other hand, it does mean that
more than one element of the range may have the same value.
-----------------------------------------------------------

Due to the miracle of floating point arithmetic, there is always
a value for "by:" where even from+I*by == from for at least some
part of the range.  This leads to one of two undesirable states:
1) more than one element of the range has the same value, as Stavros
suggests, or 2) the (size) of the range is not equal to the number
of values one would see iterating over it.

Again, these unpleasant facts of floating point life could be avoided
if from/up-to/by were constrained to be <rational>.

atw