Karl Brodowsky wrote:
Michael Zedeler schrieb:
Well... maybe. How do you specify the intended precision, then? If I want the values from 1 to 2 with step size 0.01, I guess that writing

1.00 .. 2.00

won't be sufficient. Trying to work out the step size by looking at the precision of things that are double or floats doesn't really sound so feasible, since there are a lot of holes in the actual representation, so 1.0001 may become 1.0, yielding very different results.
That is a general problem of floats. We tend to write them in decimal notation, but internally they use a representation which is binary. And it is absolutely not obvious what the "precision" of 1.0001 might be. There could be a data type like "LongDecimal" in Ruby or "BigDecimal" in Java, that actually has a knowlegde of its precision and whose numbers are fractions with a power of 10 as the denominator. But for floats I would only see the interval as reasonably clear. Even a step of 1 is coming with some problems, because an increment of 1 does not have any effect on floating point numbers like 1.03e300 or so.
Yes. Exactly my point. By the way, do we want to warn if someone writes

1e300 .. 1e301 :by(1)

given that the number implementation yields 1e300 + 1 == 1e300?

Regards,

Michael.




Reply via email to