Skip to content
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

egalite sur les floats #2492

Closed
vicuna opened this issue Jun 14, 2000 · 2 comments
Closed

egalite sur les floats #2492

vicuna opened this issue Jun 14, 2000 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jun 14, 2000

Original bug ID: 140
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug 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 =

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

@vicuna
Copy link
Author

vicuna commented Jun 14, 2000

Comment author: administrator

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 =

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

@vicuna
Copy link
Author

vicuna commented Jun 19, 2000

Comment author: administrator

That's how IEEE float arithmetic works.

@vicuna vicuna closed this as completed Jun 19, 2000
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant