You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 3490 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Pierre Lemaire
Version: 3.08.2
OS: WindosXP / Linux Debian
Submission from: pierrelemaire.rutcor.rutgers.edu (128.6.29.9)
Hi!
The behavior of Pervasives.compare does not match the specifications, when
using ocamlc under windows XP. Here is a small piece of code:
let test =
Printf.printf "test1: %s\ntest2: %s\n"
(if Pervasives.compare 0.8 nan == 0 then "eq" else "ne")
(if Pervasives.compare nan nan == 0 then "eq" else "ne")
;;
I compiled it with ocamlc (version 3.08.2) under winXP and the output is:
test1: eq
test2: eq
which is obviously wrong in the first case since, according to the
documentation,
"compare treats nan as equal to itself and less than any other float value".
This is all the more a problem, for compatibility reasons, that the behavior
is different if the program is compiled with ocamlc (version 3.08.2 also) under
Linux. Then, the output is, as expected:
test1: ne
test2: eq
I can cope with that by re-defining nan with a dummy (but real) value when I
compile the code under WinXP but, well... that's not exactly nice ;o)
All the best,
Pierre
The text was updated successfully, but these errors were encountered:
The behavior of Pervasives.compare does not match the specifications, when
using ocamlc under windows XP. [...]
Let me guess: you used the Windows version of OCaml that was compiled
with Microsoft's compilers, right? Microsoft's "cl" compiler
generates incorrect code (w.r.t. NaN) for floating-point comparisons,
and this causes the behavior of Pervasives.compare that you observed.
There isn't much we can do about it, except abandon the use of
Microsoft's compilers entirely.
You can get the correct results under Windows by using the MinGW or
Cygwin versions of OCaml. gcc does generate correct code for
floating-point comparisons.
Original bug ID: 3490
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Pierre Lemaire
Version: 3.08.2
OS: WindosXP / Linux Debian
Submission from: pierrelemaire.rutcor.rutgers.edu (128.6.29.9)
Hi!
The behavior of Pervasives.compare does not match the specifications, when
using ocamlc under windows XP. Here is a small piece of code:
let test =
Printf.printf "test1: %s\ntest2: %s\n"
(if Pervasives.compare 0.8 nan == 0 then "eq" else "ne")
(if Pervasives.compare nan nan == 0 then "eq" else "ne")
;;
I compiled it with ocamlc (version 3.08.2) under winXP and the output is:
test1: eq
test2: eq
which is obviously wrong in the first case since, according to the
documentation,
"compare treats nan as equal to itself and less than any other float value".
This is all the more a problem, for compatibility reasons, that the behavior
is different if the program is compiled with ocamlc (version 3.08.2 also) under
Linux. Then, the output is, as expected:
test1: ne
test2: eq
I can cope with that by re-defining nan with a dummy (but real) value when I
compile the code under WinXP but, well... that's not exactly nice ;o)
All the best,
Pierre
The text was updated successfully, but these errors were encountered: