caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Sean McLaughlin <seanmcl@cmu.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] float rounding
Date: Sun, 01 Oct 2006 15:36:40 +0200	[thread overview]
Message-ID: <1159709800.13405.5.camel@localhost.localdomain> (raw)
In-Reply-To: <89957A27-4B6A-4FCF-A425-1468ECFA8B62@cmu.edu>

Am Samstag, den 30.09.2006, 14:25 -0400 schrieb Sean McLaughlin:
> Hello,
> 
>    I'm using Ocaml for an interval arithmetic application.  I"m  
> curious about
> what the Ocaml parser/compiler does to float constants.  May I assume
> that for any constant I enter, eg. 3.1415... (for N digits of pi), that
> the compiler will give me a closest machine representable number?
> i.e., if I bound a constant by the previous and next floating point  
> value to
> that given me by the compiler,
> will it always be the case that my original (mathematical) constant  
> lies in that interval?

Don't think so. float_of_string is a wrapper around the strtod C
function, and the standard for this function does not require that. I
found this interesting note about how different OS implement string to
float conversion:

http://www.wrcad.com/linux_numerics.txt

To be sure your constants are the best possible you probably have to use
float_of_bits...

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


  parent reply	other threads:[~2006-10-01 13:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-30 18:25 Sean McLaughlin
2006-10-01 12:44 ` [Caml-list] " Florent Monnier
2006-10-01 13:36 ` Gerd Stolpmann [this message]
2006-10-01 16:36 ` Xavier Leroy
2006-11-23 23:00   ` David Monniaux
2006-10-03 13:41 ` Christophe Raffalli
2006-10-03 19:59 ` Christophe Raffalli
2006-10-03 21:05   ` Olivier Andrieu
2006-11-26  1:51     ` David Monniaux

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=1159709800.13405.5.camel@localhost.localdomain \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=seanmcl@cmu.edu \
    /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).