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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id BB933BBAF for ; Sun, 22 Jun 2008 21:58:34 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAC9LXkhQRFuw/2dsb2JhbACtRw X-IronPort-AV: E=Sophos;i="4.27,686,1204498800"; d="scan'208";a="14251584" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP; 22 Jun 2008 21:58:34 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1KAVho-00069A-1w; Sun, 22 Jun 2008 20:58:33 +0100 Date: Sun, 22 Jun 2008 20:58:31 +0100 To: Paolo Donadeo Cc: caml-list caml-list Subject: Re: [Caml-list] Strange behaviour of string_of_float Message-ID: <20080622195831.GA22384@annexia.org> References: <4b5157c30806220956p164d8346i3e832bc8b8666306@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4b5157c30806220956p164d8346i3e832bc8b8666306@mail.gmail.com> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; 0200,:01 blogs:98 wrote:01 caml-list:01 arithmetic:01 behaviour:01 string:02 string:02 float:03 float:03 programmer:07 red:92 strange:08 approximate:08 approximate:08 On Sun, Jun 22, 2008 at 06:56:22PM +0200, Paolo Donadeo wrote: > string_of_float is not the inverse of float_of_string, at least in > this example. Yes, you wouldn't expect it to be, because the string is an approximate base 10 representation of the float (which is itself only an approximate base 2 representation of the transcendental number pi). You might want to read a presentation called "What every computer programmer should know about floating point arithmetic". There's a PDF version here: http://blogs.sun.com/darcy/resource/Wecpskafpa-ACCU.pdf Rich. -- Richard Jones Red Hat