From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 472B3E0038 for ; Wed, 15 Jun 2022 09:00:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=O2JNypMShv13pihgRr511GMlxQbHtoH9RMmW6bncKns=; b=kLBp92pXjXizil2QFbPUsTY7+HFUhIZcZgXmrPQEQvSH4tzHJ0F6Sbz7 50OT6X3Dorr5ZpDbaMle66RCOMgyPArJw1On/iXzcbE+YJ1QCAjO3W7xZ SD1+z6BV0l1fMbsFnFg3F/SwjnusGdtfOtrAi6RVC2fhbGDdVJTR9GezA g=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=francois.pottier@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.91,300,1647298800"; d="scan'208";a="16795659" Received: from wifi-pro-82-204.paris.inria.fr ([128.93.82.204]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 09:00:39 +0200 To: Andreas Rossberg , Kenichi Asai Cc: caml-list@inria.fr References: <43238522-BFA7-4F89-8F91-9D95893A9D74@mpi-sws.org> From: =?UTF-8?Q?Fran=c3=a7ois_Pottier?= Message-ID: <1c2d63bb-877c-f40a-d228-f4b877e61b54@inria.fr> Date: Wed, 15 Jun 2022 09:00:38 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <43238522-BFA7-4F89-8F91-9D95893A9D74@mpi-sws.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] string_of_float (0.1 +. 0.2) Hi, Le 15/06/2022 à 08:22, Andreas Rossberg a écrit : > The OCaml manual does not say what the default is, but it appears to be .6 for printf (like in C), while string_of_float is equivalent to (sprintf "%.12g”) and the REPL uses .18 (which is the maximum meaningful decimal precision for 64 bit floats): Indeed, the implementation of string_of_float uses "%.12g". The manual says that string_of_float returns "the" string representation of a floating-point number. I would claim that there is a problem here -- either the manual should warn that there is a potential loss of information, or the code should be fixed so as to lose no information. -- François Pottier francois.pottier@inria.fr http://cambium.inria.fr/~fpottier/