From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 0267F7F008 for ; Thu, 26 May 2016 10:24:42 +0200 (CEST) IronPort-PHdr: 9a23:NbUv5x/RKw76v/9uRHKM819IXTAuvvDOBiVQ1KB91+8cTK2v8tzYMVDF4r011RmSDdSdt64P0rGO+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkItf6KuSt+U05j8jrvqs7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cY6Lod8JtLWKD+OqA5VqBwDTI8Mmlz6te4mwPESF6q4XsVV2ga2jtHHgXf6hXzWp655ir1q+dnniCHIcreQrU9WDDk5KBuHky7wBwbPiI0pTmEwvd7i7hW9Uqs Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=iguer.auto@gmail.com; spf=Pass smtp.mailfrom=iguer.auto@gmail.com; spf=None smtp.helo=postmaster@mail-wm0-f47.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of iguer.auto@gmail.com) identity=pra; client-ip=74.125.82.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="iguer.auto@gmail.com"; x-sender="iguer.auto@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of iguer.auto@gmail.com designates 74.125.82.47 as permitted sender) identity=mailfrom; client-ip=74.125.82.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="iguer.auto@gmail.com"; x-sender="iguer.auto@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wm0-f47.google.com) identity=helo; client-ip=74.125.82.47; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="iguer.auto@gmail.com"; x-sender="postmaster@mail-wm0-f47.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B5AQD+sUZXfy9SfUpchA99pUgBAQaIRVKNGySHKDsRAQEBAQEBAQERAQEJCwsJIS+CLoIuERUIARQHHAIDEhAPAgUWCwILAwIBAgEREQEFAS8IAQEXB4dyAQMXDqFaggeBMT4xizuBaoJYBYd8ChknDVKDWwEBCAIBHAIGEHGEXoofgjWCWQWYN4YAiCBliE4OhVtFjUgwgQ82hBtsAQGKEwEBAQ X-IPAS-Result: A0B5AQD+sUZXfy9SfUpchA99pUgBAQaIRVKNGySHKDsRAQEBAQEBAQERAQEJCwsJIS+CLoIuERUIARQHHAIDEhAPAgUWCwILAwIBAgEREQEFAS8IAQEXB4dyAQMXDqFaggeBMT4xizuBaoJYBYd8ChknDVKDWwEBCAIBHAIGEHGEXoofgjWCWQWYN4YAiCBliE4OhVtFjUgwgQ82hBtsAQGKEwEBAQ X-IronPort-AV: E=Sophos;i="5.26,367,1459807200"; d="scan'208";a="219807201" Received: from mail-wm0-f47.google.com ([74.125.82.47]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 26 May 2016 10:24:41 +0200 Received: by mail-wm0-f47.google.com with SMTP id z87so89534312wmh.0 for ; Thu, 26 May 2016 01:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=odtuLp8bRVI+TQuoItNQBDoVHlElr8QIXq5lV1Iq7TE=; b=dnshO95Nsv6pwFwf73X3/qHTNIXXABVBxh7odE9f2iSRTjs8OKVX9Y//yrhl3bXA3n l3A4z6HHtkIq/bK//NJercPj+rnFoNW3tDKZboRIEtaq510c6UYNxv9nsND1YFf2w2eX 1oMQpIIP7DOaaOPnF0fPMfprYFlC0/vWevgBk4NT3XyBYL22WNuOE3Qo9HlBO9ibyWXb Y+qPkRxQpqhTKnrlo1lxjcgmRd9gM1dD62TKpULOEv8LzEN1aFmvWqviIZMlC2SAzXbE fWQOSeChRsUyD9ieI0MJJdyeOaxM70Avrv/drFLgDits5+LpgYN9qtWKMQYgRcdlK+ZP tAmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=odtuLp8bRVI+TQuoItNQBDoVHlElr8QIXq5lV1Iq7TE=; b=BO5d18yqQiRBzTe3HCYjkP98dIvbpTjHcGYHKhdHg0CwqK04YXEgTpAv/sURZpHwAx 1hyTXdbTb88zbtkvoRmy1H+Cp4c/256KhkLKHKquPghV0WreWfAcS7ekNUfJrKpK2Urc wBECuSfedeo8NiVC44C6TVwyAnfGsPOTN/q9WX6KsxWxTpmIaYpqnuRnDubLIu9RUEQy nDn/2XCaqNfr/LF1AY/v/TSwKnXMH3jFTE0BQHfCfoHO70Yn9S1zs6z/i0wtkGju/zPu 8d0VjveaIyhXC8JKFSGhjrld59AzHemcz5/P7s2EOP1CRjRMFieMQ16Cwu72Y8cvrssL NJzw== X-Gm-Message-State: ALyK8tIsNipE0uqvWWOVnkE15TXLMkokuRcIoUSV0EsDzPk+gyav2zMVO3iRznW0T24qug== X-Received: by 10.28.234.221 with SMTP id g90mr2324726wmi.30.1464251081080; Thu, 26 May 2016 01:24:41 -0700 (PDT) Received: from [129.175.29.53] (lri29-53.lri.fr. [129.175.29.53]) by smtp.gmail.com with ESMTPSA id n15sm13075610wjr.1.2016.05.26.01.24.40 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 May 2016 01:24:40 -0700 (PDT) To: caml-list@inria.fr From: Mohamed Iguernlala Message-ID: <5746B2C7.2030608@gmail.com> Date: Thu, 26 May 2016 10:24:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Caml-list] Is this a bug in Num.float_of_num ? Hi, I came to the following "stange" behavior when using the function float_of_num. I don't know if this should be considered as a bug, since this function has no specification (in num.mli *) The float "f = 6004799503160661. /. 18014398509481984." has an exact representation on 64 bits. Its value is 0.333333333333333314829616256247390992939472198486328125 However, when using float_of_num to compute the float corresponding to the number above represented as a num, the result is slightly different. In fact, the value returned for the expression fnum = Num.float_of_num (Num.num_of_string "6004799503160661/18014398509481984") is 0.333333333333000025877623784253955818712711334228515625 I tried to investigate the reason of this difference. It seems that it is due to the (default) value of the constant "floating_precision"[1] in file arith_flags.ml of num library: it is equal to 12 instead of 54 (I think) for 64bits standard floats representation. How should this situation be interpreted ? (a) Should one explicitly modify the value of the reference "floating_precision" before calling function float_of_num ? (b) Should the function be parametrized by a precision (which is better than modifying global references like in (a) ) ? (c) Other suggestion / solution ? I attach a standalone file with relevant parts of Nums, Ratio, Arith_flags, and Int_misc to reproduce this behavior and to easily play with the value of "floating_precision". Regards, Mohamed Iguernlala. [1] https://github.com/ocaml/ocaml/blob/4.03.0/otherlibs/num/arith_flags.ml#L22 PS. I have not seen any constant in arith_flags.ml about the min/max value of the exponent ... -- Senior R&D Engineer, OCamlPro Research Associate, VALS team, LRI. http://www.iguer.info https://fr.linkedin.com/in/mohamed-iguernlala-71515979