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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 2568ABC50 for ; Tue, 3 Oct 2006 21:59:06 +0200 (CEST) Received: from smTp.neuf.fr (sp604003mt.neufgp.fr [84.96.92.56]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k93Jx5IH008897 for ; Tue, 3 Oct 2006 21:59:05 +0200 Received: from [192.168.144.3] ([84.4.222.28]) by sp604003mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-5.05 (built Feb 16 2006)) with ESMTP id <0J6K009MMSUHXR30@sp604003mt.gpm.neuf.ld> for caml-list@inria.fr; Tue, 03 Oct 2006 21:59:05 +0200 (CEST) Date: Tue, 03 Oct 2006 21:59:45 +0200 From: Christophe Raffalli Subject: Re: [Caml-list] float rounding In-reply-to: <89957A27-4B6A-4FCF-A425-1468ECFA8B62@cmu.edu> To: Sean McLaughlin Cc: caml-list@inria.fr Message-id: <4522C131.9010400@univ-savoie.fr> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 8BIT References: <89957A27-4B6A-4FCF-A425-1468ECFA8B62@cmu.edu> User-Agent: Thunderbird 1.5.0.7 (Macintosh/20060909) X-Miltered: at discorde with ID 4522C109.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; christophe:01 raffalli:01 christophe:01 raffalli:01 univ-savoie:01 rounding:01 ocaml:01 ocaml:01 parser:01 compiler:01 compiler:01 printf:01 scanf:01 printf:01 sqrt:01 Sean McLaughlin a écrit : > 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? > By the way, float constants need to be written in hexadecimal and this is missing to the printf/scanf functions (it is what man printf says at least) ... just compute how many decimals you need to write the exact value of 2^{-n} as a decimal float constant (0,5 0,25 0,125 0,625e-1 0,3125e-1 ...). Then, I am not sure the algorithm used to parse the constant will give you the correct value and you will never know how many decimals you need to write your constant. The only problem with float and hexadecimal is to learn the hexadecimals of pi, e, ln 2, sqrt 2, ... ;-) Christophe Raffalli