Just a question: Anyone know why DoubleRange does ...
# stdlib
v
Just a question: Anyone know why DoubleRange does not exists in the StdLib ?
c
because Double is neither discrete nor exact type.
E.g. what are the steps between 1.0 and 2.0? between 1.0 and 1.1? 1.0 and 1.0000001?
v
You can specify the step for Int and Long, why not for Double
c
because step involves math operations on a double, which are not always deterministic exact.
k
*exact
✔️ 1
IEEE floating point math is definitely deterministic.
s
Seems like an odd reason. Has there been an official response to this ?
c
how is that an odd reason?
s
Because if one has chosen to work with Double in using a DoubleRange why should its inexactness not carry over?
If anything I would expect such a type to handle the common gotchas that probably would arise from this instead of redoing it poorly as was done in slack maybe two months ago
c
I'd say because it's error-prone and bad style in most situations. If one is in a situation where that would be a good idea, nothing prevents them from implementing DoubleRange themselves.
Actually stdlib has
ClosedDoubleRange
and
ClosedFloatingPointRange
which do make sense in terms of checking if a range contains value. Just not for iteration.
👍 1
s