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

Camllight: ca float entre 2 os #2392

Closed
vicuna opened this issue Mar 13, 2000 · 2 comments
Closed

Camllight: ca float entre 2 os #2392

vicuna opened this issue Mar 13, 2000 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Mar 13, 2000

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

Bug description

Bonjour,

Desolee de vous deranger si ce qui suit (qui me semble etre un bug) est
deja repertorie.
Je suis en cls74 sur Mac et les floats ont un comportement bizarre (cf
ci-dessous).
En esperant vous etre utile,
Marie-Catherine Daniel-Vatonne

#let pp =((0.24 -.0.27)*. 1000.);;

let mm=((0.27 -.0.3)*. 1000.);;

pp : float = -30.0
#mm : float = -30.0
#pp = mm;;

  • : bool = false
    #pp < mm;;
  • : bool = true
    #(int_of_float pp);;
  • : int = -30
    #(int_of_float mm);;
  • : int = -29
    #abs_float pp;;
  • : float = 30.0
    #abs_float mm;;
  • : float = 30.0
    #abs_float pp =abs_float mm;;
  • : bool = false

(remarque le *1000 n'est la que pour pouvoir faire int_of_float)


Marie-Catherine DANIEL-VATONNE
Maitre de Conf. en Informatique
Assistant Professor in Computer Science
IREMIA, Universite de la Reunion
15 rue R. Cassin -BP7151-
97 715 St Denis Messag 9
Phone :
Foreign countries: +262+93-82-79 fax:93-82-60
Metropole: 0262+93-82-79 fax:93-82-60
Url: http://www.univ-reunion.fr/~mcdv

@vicuna
Copy link
Author

vicuna commented Mar 13, 2000

Comment author: administrator

Je suis en cls74 sur Mac et les floats ont un comportement bizarre (cf

#let pp =((0.24 -.0.27). 1000.);;
#let mm=((0.27 -.0.3)
. 1000.);;

En fait, si vous calculez pp +. 30. et mm +. 30. vous verrez que l'un est
legerement superieur a 30 et l'autre legerement inferieur, ce qui explique
tout.

C'est pareil quels que soient le langage et la machine, pourvu que les
flottants
soient au standard IEEE-754. C'est deja moins bizarre si on les affiche avec
tous les chiffres (par exemple en utilisant printf).

-- Damien

@vicuna vicuna closed this as completed Mar 13, 2000
@vicuna
Copy link
Author

vicuna commented Mar 14, 2000

Comment author: administrator

Bonjour,

Desolee de vous deranger si ce qui suit (qui me semble etre un bug) est
deja repertorie.
Je suis en cls74 sur Mac et les floats ont un comportement bizarre (cf
ci-dessous).
En esperant vous etre utile,
Marie-Catherine Daniel-Vatonne

#let pp =((0.24 -.0.27). 1000.);;
let mm=((0.27 -.0.3)
. 1000.);;
pp : float = -30.0
#mm : float = -30.0
#pp = mm;;

  • : bool = false

L'affichage des flottants n'affiche pas tous les chiffres
significatifs par défaut. On peut considérer que c'est un petit bug.
Cependant, on peut voir la différence entre pp et mm comme suit:

#pp -. mm;;

  • : float = -5.68434188608e-14

Et même faire afficher plus de chiffres significatifs à l'aide des
fonctions du module "printf":

#open "printf";;

#printf "%.20f\n" pp;;
-30.00000000000002842171
#printf "%.20f\n" mm;;
-29.99999999999997157829

Cordialement,

  • Xavier Leroy

@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