From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id 8831A5D5 for ; Wed, 15 Jun 2022 07:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=to:cc:references:from:message-id:date:mime-version: in-reply-to:content-transfer-encoding:subject:reply-to: sender:list-id:list-help:list-subscribe:list-unsubscribe: list-post:list-owner:list-archive; bh=O2JNypMShv13pihgRr511GMlxQbHtoH9RMmW6bncKns=; b=HQOLyMq7RJziF1ZMT5e+fGz8ucF/p6GEn5syU89zkZ/12ONrMFxpmw+C q8YvIiQu8MhaGn76PJzETxGK6rHzcFEkz3b7ck5UvboAB+BlhzLvi/J69 fpvDFRqFy0EHDxIAqhNa8UUla64/bzDFyEvcXUbYWkBYyiwQDxjHHH+Rz o=; Received-SPF: SoftFail (mail2-relais-roc.national.inria.fr: domain of caml-list-owner@inria.fr is inclined to not designate 128.93.162.160 as permitted sender) identity=mailfrom; client-ip=128.93.162.160; receiver=mail2-relais-roc.national.inria.fr; envelope-from="caml-list-owner@inria.fr"; x-sender="caml-list-owner@inria.fr"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:192.134.164.0/24 mx ~all" Received-SPF: None (mail2-relais-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@sympa.inria.fr) identity=helo; client-ip=128.93.162.160; receiver=mail2-relais-roc.national.inria.fr; envelope-from="caml-list-owner@inria.fr"; x-sender="postmaster@sympa.inria.fr"; x-conformance=spf_only Authentication-Results: mail2-relais-roc.national.inria.fr; spf=SoftFail smtp.mailfrom=caml-list-owner@inria.fr; spf=None smtp.helo=postmaster@sympa.inria.fr; dkim=pass (signature verified) header.i=@inria.fr X-IronPort-AV: E=Sophos;i="5.91,300,1647298800"; d="scan'208";a="41081769" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 15 Jun 2022 09:00:41 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 34FF1E02A4; Wed, 15 Jun 2022 09:00:41 +0200 (CEST) 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=; 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) Reply-To: =?UTF-8?Q?Fran=c3=a7ois_Pottier?= X-Loop: caml-list@inria.fr X-Sequence: 18795 Errors-To: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: 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/