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] 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: 2004-07-15 (12:38)
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.


Markus Mottl

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: