Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-10-14 (23:45)
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 Archives:
Bug reports: FAQ:
Beginner's list: