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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus@o...>
Subject: Re: [Caml-list] min, max and nan
On Wed, 14 Jul 2004, Yaron Minsky wrote:
> When using ocaml 3.07, I tried and failed to come up with a polymorphic
> min that behaved reasonably in this case, that is, that returned
> nan when either argument is nan.  With 3.08, this is now doable.
> Here's how it works:

Another possibility is to use "classify_float":

  let nmin x y =
    if classify_float x = FP_nan || classify_float y = FP_nan then nan
    else min x y

This is actually even more efficient.

> Still, we don't quite escape from the oddities of nan.  We still get
> order dependence in the case of larger data structures that include
> nan's:

I think this could be fixed by making use of the Obj-module, though this
would look a little bit messy.

Regards,
Markus

-- 
Markus Mottl          http://www.oefai.at/~markus          markus@oefai.at

-------------------
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