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
equality operators in OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-07-25 (12:05)
From: Peng Zang <peng.zang@g...>
Subject: Re: [Caml-list] equality operators in OCaml
Hash: SHA1

On Friday 25 July 2008 06:34:54 am Christophe TROESTLER wrote:
> On Thu, 24 Jul 2008 21:40:36 -0400, Peng Zang wrote:
> > On Thursday 24 July 2008 06:32:36 pm Jon Harrop wrote:
> > > There are some complications here. Firstly, NaN has multiple
> > > representations that may or may not be physically equal but is always
> > > structurally unequal to itself.
> >
> > Yeah, that always seemed broken to me.  If two things are physically
> > equal (they occupy the same memory space) it doesn't make sense for them
> > to be structurally unequal (contain different content).  Personally, one
> > of the first things I did is redefined (=) to fix this.
> Humm... is certainly
> a good read...
> My 0.02¤,
> C.

I second that.  Particularly relevant is how there is not one unique NaN but a 
family of them.  OCaml has three treatments for them:

1) (=) treats all NaNs as different (even if they may in fact, at the bit 
level, be the same)

2) (compare) treats all NaNs as the same (even if they may in fact, at the bit 
level be different)

3) (==) two NaNs are equal iff they share the same memory

(2) tends to come up the most often as you typically don't care what kind of 
NaN it is, as long as it is one.

Version: GnuPG v2.0.7 (GNU/Linux)