From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA28589; Wed, 15 Oct 2003 01:45:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA31784 for ; Wed, 15 Oct 2003 01:45:31 +0200 (MET DST) Received: from mail1.tpgi.com.au ([203.12.160.57]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9ENjR101250 for ; Wed, 15 Oct 2003 01:45:29 +0200 (MET DST) Received: from syd-ts18-2600-085.tpgi.com.au (syd-ts18-2600-085.tpgi.com.au [203.58.21.85]) by mail1.tpgi.com.au (8.11.6/8.11.6) with ESMTP id h9ENi4119729; Wed, 15 Oct 2003 09:44:05 +1000 Subject: Re: [Caml-list] Weird behavior with nan's and min/max From: skaller Reply-To: skaller@ozemail.com.au To: Yaron Minsky Cc: caml-list@inria.fr In-Reply-To: <63219.141.155.88.179.1066164734.squirrel@minsky-primus.homeip.net> References: <51792.141.155.88.179.1066142234.squirrel@minsky-primus.homeip.net> <54490.141.155.88.179.1066143413.squirrel@minsky-primus.homeip.net> <63219.141.155.88.179.1066164734.squirrel@minsky-primus.homeip.net> Content-Type: text/plain Message-Id: <1066175022.17727.9.camel@pelican> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 15 Oct 2003 09:43:43 +1000 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ozemail:01 yaron:01 minsky:01 weirdness:01 conforming:01 monomorphic:01 monomorphic:01 bool:01 semantics:01 semantics:01 evaluates:01 evaluates:01 ocaml:01 equality:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 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