caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Is this a bug in Num.float_of_num ?
Date: Thu, 26 May 2016 10:57:41 +0200	[thread overview]
Message-ID: <5746BA85.4030100@inria.fr> (raw)
In-Reply-To: <5746B2C7.2030608@gmail.com>

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

  reply	other threads:[~2016-05-26  8:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26  8:24 Mohamed Iguernlala
2016-05-26  8:57 ` Xavier Leroy [this message]
2016-05-26  9:16   ` Mohamed Iguernlala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5746BA85.4030100@inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).