Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Christophe Raffalli <christophe.raffalli@u...>
Subject: Re: [Caml-list] float rounding
Sean McLaughlin a écrit :
> 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?

This is not really an answer to your question but I wrote an OCaml binding to the function
to change the rounding mode of the proc. You can download it from (the fifth item) 
http://www.lama.univ-savoie.fr/~raffalli/?page=soft&lang=en

(four rounding modes are availaible: closest, toward +inf, -inf and zero. The mode far from zero
is not available)

And to answer your question, the default rounding mode is "closest" in OCaml like in C (I think).


-- 
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------