caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <damien.doligez@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] A problem with nan.
Date: Fri, 21 May 2004 00:45:09 +0200	[thread overview]
Message-ID: <5908F540-AAAF-11D8-9E52-00039310CAE8@inria.fr> (raw)
In-Reply-To: <200405202142.56044.jdh30@cam.ac.uk>


On May 20, 2004, at 22:42, Jon Harrop wrote:

> # 2.=nan;;
> - : bool = false
> # [2.]=[nan];;
> - : bool = true
>
> when "=" compares structures recursively so you'd expect it to give 
> the same answer in both cases?

We have contradictory requirements here:
1. We want "=" on floats to be IEEE754 equality.
2. We want "=" on structures to be compatible with "=" on their 
elements.
3. We want "=" on structures to be based on "compare".
4. We want "compare" to be a total ordering.

Since IEEE754 equality is not a reflexive relation, there is no way
to get all four properties.

In the current version of O'Caml, we have 1, 3, and 4.  In the next
version we will have 1, 2, and 4: "compare" and "=" will have slightly
different behaviour, but "=" will be compatible with itself.  This
will make "compare" a valid comparison function for List.sort, for
all types of data (currently it doesn't work for floats).

But "compare nan nan" will return 0, while "nan = nan" will
return false (as mandated by IEEE754).

-- Damien

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


  parent reply	other threads:[~2004-05-20 22:45 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-19 17:24 [Caml-list] Large projects in OCaml ramu ramamurthy
2004-05-19 21:33 ` Jon Harrop
2004-05-19 23:04   ` David J. Trombley
2004-05-20 16:31   ` Eric Stokes
2004-05-20 17:37     ` Jon Harrop
2004-05-20 20:30       ` Eric Stokes
2004-05-20 21:04         ` Jon Harrop
2004-05-20 21:41           ` Eric Stokes
2004-05-21 11:28             ` Jon Harrop
2004-05-21 12:49               ` Ville-Pertti Keinonen
2004-05-21 16:27                 ` Jon Harrop
2004-05-24  3:07               ` Jacques GARRIGUE
2004-05-24  5:20                 ` skaller
2004-05-24 12:14                   ` Jacques GARRIGUE
2004-05-24 13:54                     ` skaller
2004-05-24 14:20                       ` Xavier Leroy
2004-05-24 16:48                         ` Alex Baretta
2004-05-24 17:38                           ` brogoff
2004-05-25  5:25                           ` Alan Schmitt
2004-05-24 19:24                         ` skaller
2004-05-24 19:52                           ` Brandon J. Van Every
2004-05-24 14:20                       ` Daniel Bünzli
2004-05-24 19:34                         ` skaller
2004-05-24 16:49                       ` james woodyatt
2004-05-19 21:38 ` Richard Jones
2004-05-20  8:46   ` skaller
2004-05-20 11:56     ` [Caml-list] A problem with nan sejourne kevin
2004-05-20 20:42       ` Jon Harrop
2004-05-20 22:24         ` David J. Trombley
2004-05-20 22:45         ` Damien Doligez [this message]
2004-05-20 13:10     ` [Caml-list] Large projects in OCaml Jon Harrop
2004-05-20 16:23       ` skaller
2004-05-20  6:35 ` David Monniaux
2004-05-20  7:17   ` Dustin Sallings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5908F540-AAAF-11D8-9E52-00039310CAE8@inria.fr \
    --to=damien.doligez@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).