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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 5EC8E7F008 for ; Thu, 26 May 2016 10:57:41 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.26,367,1459807200"; d="scan'208";a="179074434" Received: from estephe.paris.inria.fr (HELO [128.93.64.229]) ([128.93.64.229]) by mail3-relais-sop.national.inria.fr with ESMTP; 26 May 2016 10:57:41 +0200 To: caml-list@inria.fr References: <5746B2C7.2030608@gmail.com> From: Xavier Leroy Message-ID: <5746BA85.4030100@inria.fr> Date: Thu, 26 May 2016 10:57:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <5746B2C7.2030608@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Is this a bug in Num.float_of_num ? On 26/05/2016 10:24, Mohamed Iguernlala wrote: > 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. float_of_ratio and float_of_num are very imprecise in OCaml 4.02 and earlier. They were reimplemented in OCaml 4.03 in a way that should give correct roundings. So, make sure you're using 4.03, and if the bug is still there, please file a report on Mantis. Best, - Xavier Leroy