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 EAAB5BC50 for ; Sun, 1 Oct 2006 14:41:39 +0200 (CEST) Received: from mail.libertysurf.net (mx-out.libertysurf.net [213.36.80.91]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k91CfdX6027707 for ; Sun, 1 Oct 2006 14:41:39 +0200 Received: from dyn-83-156-166-48.ppp.tiscali.fr (83.156.166.48) by mail.libertysurf.net (7.3.105.2) id 44EAB335003E9D31; Sun, 1 Oct 2006 14:35:54 +0200 From: Florent Monnier Organization: l'Association Linux-Nantes To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] float rounding Date: Sun, 1 Oct 2006 14:44:33 +0200 User-Agent: KMail/1.8.2 References: <89957A27-4B6A-4FCF-A425-1468ECFA8B62@cmu.edu> In-Reply-To: <89957A27-4B6A-4FCF-A425-1468ECFA8B62@cmu.edu> Cc: Sean McLaughlin MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200610011444.33789.fmonnier@linux-nantes.fr.eu.org> X-Face: %&4hE">2*7f{Xg6=+.^x-$p!&Dqj[S+f.Gi]$mALuLJC)MLDO|_=blD7VAFU1JbS3(W;9RI;6%4TPViRI"Mg+ 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? For the concrete exemple of PI, perhaps you could use a mathematical calculation to get its best value: # 4. *. atan 1. ;; - : float = 3.14159265358979312 (but the last number '2' is wrong) For other constants, maybe there are equivalent things?