New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
probleme d'arrondi #2972
Comments
Comment author: administrator On Wed, Sep 26, 2001 at 08:14:47PM +0200, markey@lsv.ens-cachan.fr wrote:
Que ce soit en Fortran, en C, en Pascal ou en OCaml, les opérations En particulier, l'égalité ne devrait jamais être utilisée: au lieu du C'est du moins ce qu'on m'a appris à l'école, à une époque où Caml D'ailleurs - petite remarque à mes chers collègues - je ne comprends -- |
Comment author: administrator
Le toplevel Caml affiche les flottants avec environ 12 chiffres let rec h n a b = if (n=0) then b else h (n-1) a (b+.a);;val h : int -> float -> float -> float = let x = h 10000 0.0001 0.;;val x : float = 1 x -. 1.0;;
Printf.printf "%.20g\n" x;;0.99999999999990618615
L'arithmétique flottante est ainsi faite: pleine de surprises :-)
|
Original bug ID: 545
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Bonjour
(I hope you speak french... Tell me otherwise, I can translate... :-))
je ne l'ai vu dans aucun bouquin) :
% ocaml
Objective Caml version 3.02
let rec h n a b = if (n=0) then b else h (n-1) a (b+.a);;
val h : int -> float -> float -> float =
h 100 0.01 0.;;
1. <= h 100 0.01 0.;;
h 10000 0.0001 0.;;
1. <= h 10000 0.0001 0.;;
Il y a manifestement un probleme d'arrondi, mais neanmoins la valeur
affichee est correcte.
Le meme bug se produit avec ocaml 2.04...
Amicalement,
--
Nicolas MARKEY
The text was updated successfully, but these errors were encountered: