Repair to floating point enumerations?

Isaac Dupree isaacdupree at charter.net
Thu Oct 16 17:31:50 EDT 2008


Christopher Lane Hinson wrote:
> 
> I agree with David, we should be using multiplication, not addition.
> However, I think that under the law of least surprise, we should
> require that for all a,b,z:
> 
> all (\x -> x >= a && x < z || x <= a && x > z) [a,b..z].

so that [0,0.1..0.3] doesn't include the terminating value 
that's a little more than the literal 0.3?

> For example, anything in the neighborhood of this is just unfair, even 
> if it's within David's fudge factor:
> 
> Prelude> map (\x -> 1 / (x-0.6)) [0,0.1..0.55]
> [-1.6666666666666667,-2.0,-2.5,-3.333333333333334,-5.000000000000001,-10.000000000000002,Infinity] 

but that's a significant fudge, 0.5 versus 0.55 versus 0.6 
-- right?

-Isaac


More information about the Haskell-prime mailing list