Hugh Perkins wrote:
On 8/22/07, Twan van Laarhoven <[EMAIL PROTECTED]> wrote:
But Double is already quite badly behaved:
 > let x = 1e20
 > Prelude> 1 + (x - x)
 > 1.0
 > Prelude> (1 + x) - x
 > 0.0

Ewwww.  Whilst that's understandable and unavoidable, that kindof
rings alarm bells for folds of Doubles in an automatic threading
situation.  Ie, if we split our fold between 4 cores, we might get a
different answer than if we split it between 8 cores?

Yep, Double's (+) isn't associative.

I was trying to come up with ANY common mathematical property that Double fulfills and this was what I came up with:

--> for all x::Float.  not (x > x + 1)

I'm not even sure it's true in the presence of very large numbers, optimizations and extra precision being added in the CPU. Note that it's not (x <= x + 1) because of NaN.

Is Double's (+) commutative? I don't know for sure. Its (==) isn't reflexive (is it transitive? probably, at least if there aren't too many optimizations, but floating-point transitive equality isn't very useful).

--> Okay... so (+), (*), (==) are probably symmetric too.

Any others?

Isaac
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to