From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6DDC7BC50 for ; Sun, 1 Oct 2006 15:36:56 +0200 (CEST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k91Dat7G017891 for ; Sun, 1 Oct 2006 15:36:56 +0200 Received: from [84.58.189.123] (helo=gate.lan.gerd-stolpmann.de) by mrelayeu.kundenserver.de (node=mrelayeu1) with ESMTP (Nemesis), id 0MKwpI-1GU1Up34U4-0004VR; Sun, 01 Oct 2006 15:36:46 +0200 Received: from flakew.lan.gerd-stolpmann.de (fw.lan.gerd-stolpmann.de [192.168.1.1]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id 4B371C0AD; Sun, 1 Oct 2006 15:36:41 +0200 (CEST) Subject: Re: [Caml-list] float rounding From: Gerd Stolpmann To: Sean McLaughlin Cc: caml-list@inria.fr In-Reply-To: <89957A27-4B6A-4FCF-A425-1468ECFA8B62@cmu.edu> References: <89957A27-4B6A-4FCF-A425-1468ECFA8B62@cmu.edu> Content-Type: text/plain Date: Sun, 01 Oct 2006 15:36:40 +0200 Message-Id: <1159709800.13405.5.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de login:a6865a839c0178d9aa0ce41878507ea2 X-Miltered: at concorde with ID 451FC477.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; rounding:01 gerd:01 stolpmann:01 ocaml:01 ocaml:01 parser:01 compiler:01 compiler:01 gerd:01 stolpmann:01 viktoriastr:01 64293:01 darmstadt:01 6151:01 6151:01 Am Samstag, den 30.09.2006, 14:25 -0400 schrieb Sean McLaughlin: > Hello, > > I'm using Ocaml for an interval arithmetic application. I"m > curious about > what the Ocaml parser/compiler does to float constants. May I assume > that for any constant I enter, eg. 3.1415... (for N digits of pi), that > the compiler will give me a closest machine representable number? > i.e., if I bound a constant by the previous and next floating point > value to > that given me by the compiler, > will it always be the case that my original (mathematical) constant > lies in that interval? Don't think so. float_of_string is a wrapper around the strtod C function, and the standard for this function does not require that. I found this interesting note about how different OS implement string to float conversion: http://www.wrcad.com/linux_numerics.txt To be sure your constants are the best possible you probably have to use float_of_bits... Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------