caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Damien Doligez <damien.doligez@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] float pretty-printing precision, once more.
Date: Tue, 10 Dec 2002 16:47:21 +0100	[thread overview]
Message-ID: <20021210164721.C7440@pauillac.inria.fr> (raw)
In-Reply-To: <97FCFA94-0C40-11D7-B751-0003930FCE12@inria.fr>; from damien.doligez@inria.fr on Tue, Dec 10, 2002 at 02:09:19PM +0100

> [string_of_float loses precision on floating-point numbers]
> In the current working version (3.06+18), the precision used by
> string_of_float has been increased to 17 digits.

Yes, this was my feeble attempt to work around the precision loss
using only what is available, i.e. sprintf.  However, as you say:

> However, it has the unfortunate side-effect of revealing this
> awful truth about FP numbers: many "interesting" numbers are
> impossible to represent in floating-point.  For example:
> 
>    # 0.1;;
>    - : float = 0.10000000000000001
> 
> There is no floating-point number equal to 0.1 and the
> best approximation you can get is 0.10000000000000001.

If that was really the best approximation, there would be nothing to
argue.  But both 0.10000000000000001 and 0.1 read back as identical
floats, so the latter should be printed instead, but sprintf (on
Linux at least) is too stupid to realize this.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2002-12-10 15:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-09 23:04 jeanmarc.eber
2002-12-09 23:46 ` Yaron M. Minsky
2002-12-10  0:07 ` Brian Hurt
2002-12-10  2:13 ` David Chase
2002-12-10  9:49 ` Xavier Leroy
2002-12-10 13:09 ` Damien Doligez
2002-12-10 15:37   ` Jacques Carette
2002-12-10 15:47   ` Xavier Leroy [this message]
2002-12-11  4:03     ` David Chase
2002-12-12  1:41       ` David Chase

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=20021210164721.C7440@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=damien.doligez@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).