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
float vs generic equality... #3241
Comments
Comment author: administrator
You've hit a delicate issue with generic equality (what you've defined When (=) is used with type float -> float -> bool, the compiler However, generic equality (eq) is defined as x = y iff compare x y = 0,
nan is not less than infinity, nor greater than infinity, so both are
Here you get the correct IEEE behavior.
This is normal according to IEEE equality semantics. Think of it in
It is a bug, of the painful-to-fix kind :-) I know how to modify generic
|
Comment author: administrator Since 2004/11, generic equality on floats behaves like IEEE equality. |
Original bug ID: 963
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Jacek Chrzaszcz
Version: 3.04&3.02
OS: Mandrake/Redhat Linux
Submission from: fw-gw-atm.mimuw.edu.pl (193.0.96.15)
Hello,
When I define
let eq = (=)
I understand that that results of (eq a b) and (a=b) may be different. But I
dont understand a few of them:
eq nan infinity;;
nan=infinity;;
On the other hand:
eq 0. ~-.0.;;
0. = ~-.0.;;
so positive and negative zero are identified even though they are printed
diffrently and give different values in operations:
1./.0. = 1./. ~-.0.;;
eq (1./.0.) (1./. ~-.0.);;
The above, together with (eq nan infinity = true) and (eq nan neg_infinity =
true) make the generic equality non-transitive, which is a bit surprising...
Is this a bug or a feature ? I always thought that (eq) is something like "are
the representations of two things equal ?", but evidently it is more
complicated...
May-be the difference between (eq) and (=) for floats should be explained in the
manual... or a FAQ.
Jacek
The text was updated successfully, but these errors were encountered: