| Anonymous | Login | Signup for a new account | 2013-06-20 01:27 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0000140 | OCaml | OCaml general | public | 2000-06-14 16:53 | 2000-06-19 17:04 | |||
| Reporter | administrator | |||||||
| Assigned To | ||||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||
| Status | closed | Resolution | no change required | |||||
| Platform | OS | OS Version | ||||||
| Product Version | ||||||||
| Target Version | Fixed in Version | |||||||
| Summary | 0000140: egalite sur les floats | |||||||
| Description | Full_Name: Vincent Cremet Version: ocaml 3.00 OS: SunOS sun-demons 5.7 Generic_106541-04 sun4u sparc Submission from: ext2.lri.fr (129.175.15.5) Bonjour, le probleme touche a la comparaison de nombres de type float. Il semble qu'il y ait une incoherence : Objective Caml version 3.00 # let decimales t = fst (modf t);; val decimales : float -> float = <fun> # decimales 1.14;; - : float = 0.140000 # decimales 2.14;; - : float = 0.140000 # (decimales 1.14) = (decimales 2.14);; - : bool = false # 0.140000 = 0.140000;; - : bool = true Cordialement, Vincent Cremet. Stagiaire DEA - equipe Demons au LRI | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0002123) administrator (administrator) 2000-06-14 20:36 |
>From: cremet@lri.fr >le probleme touche a la comparaison de nombres de >type float. Il semble qu'il y ait une incoherence : > > Objective Caml version 3.00 > ># let decimales t = fst (modf t);; >val decimales : float -> float = <fun> ># decimales 1.14;; >- : float = 0.140000 ># decimales 2.14;; >- : float = 0.140000 ># (decimales 1.14) = (decimales 2.14);; >- : bool = false ># 0.140000 = 0.140000;; >- : bool = true Bienvenue dans le monde des nombres flottants ou tout est flou et rien n'est jamais aussi simple qu'en math. Pour comprendre ce qui se passe: # Printf.printf "%.20f" (decimales 1.14);; 0.13999999999999990000- : unit = () # Printf.printf "%.20f" (decimales 2.14);; 0.14000000000000012000- : unit = () # Printf.printf "%.20f" 0.140000;; 0.14000000000000001000- : unit = () Les trois nombres flottants (decimales 1.14), (decimales 2.14), et 0.140000 sont differents (et aucun n'est egal au nombre rationnel 0.14), mais l'affichage par defaut les arrondit malencontreusement. -- Damien |
|
(0002124) administrator (administrator) 2000-06-19 17:04 |
That's how IEEE float arithmetic works. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2005-11-18 10:13 | administrator | New Issue | |
| Copyright © 2000 - 2011 MantisBT Group |