Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Weird behavior with nan's and min/max
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@o...>
Subject: Re: [Caml-list] Weird behavior with nan's and min/max
On Wed, 2003-10-15 at 06:52, Yaron Minsky wrote:

> The second weirdness is the breaking of (==) => (=), since "nan == nan"
> evaluates to true and "nan = nan" evaluates to false.

The problem here is IEEE semantics, not Ocaml.

The idea that x = x isn't universally true is 
mathemtically absurd.

One solution is to define a new float specific
IEEE conforming equality comparator 

	iEEE_eq : float -> float -> bool

and change the semantics of = to be mathematically
sound with

	Nan = Nan ==> true

but possibly more expensive to evaluate.

This means that polymorphic comparisons agree with
monomorphic ones, and leaves it up to the numerical
programmer to use the monomorphic iEEE_eq comparison 
it is needed. [Possibly the iEEE_eq function can be
given an infix symbol?]



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners