English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
float rounding
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-10-01 (13:36)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] float rounding
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:


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

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