Details
-
Type:
Defect
-
Status:
Closed
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: Backlog
-
Component/s: None
-
Labels:None
Description
I would expect the attached clojure program to have the same output as the attached java program. However, their output differs. The following is a unidiff from the clojure output to the java output, i.e., each line beginning with a minus sign is what I would consider wrong output, and the corresponding line beginning with a plus sign is the correct output.
@@ -14,3 +14,3 @@
- <= 0 NaN true
- <= NaN 1 true
- <= NaN NaN true
+ <= 0 NaN false
+ <= NaN 1 false
+ <= NaN NaN false
@@ -22,3 +22,3 @@ - >= 0 NaN true
- >= NaN 1 true
- >= NaN NaN true
+ >= 0 NaN false
+ >= NaN 1 false
+ >= NaN NaN false
Here Java follows IEEE 754; see also <http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#153654>.
I suspect the bug is because clojure.lang.Numbers.lte(x,y) is implemented by negating the result of lt(y,x), and similarly for gte: <http://github.com/richhickey/clojure/blob/65ae4928119a50e892bc33e8cbb47a82ebef98ee/src/jvm/clojure/lang/Numbers.java#L193>.
This is with Clojure 1.2.0-master-SNAPSHOT (git hash 65ae4928119a50e892bc33e8cbb47a82ebef98ee).
I mentioned this on the Google group, but no-one commented anything: <http://groups.google.com/group/clojure/browse_thread/thread/623d7f50fafaa816>.
Converted from http://www.assembla.com/spaces/clojure/tickets/354
Attachments:
nan-comparison.clj - https://www.assembla.com/spaces/clojure/documents/bSK-9AzyGr35jbeJe5cbLr/download/bSK-9AzyGr35jbeJe5cbLr
nan.java - https://www.assembla.com/spaces/clojure/documents/bSLbjAzyGr35jbeJe5cbLr/download/bSLbjAzyGr35jbeJe5cbLr
c-nan.txt - https://www.assembla.com/spaces/clojure/documents/bSLdpEzyGr35jbeJe5cbLr/download/bSLdpEzyGr35jbeJe5cbLr
j-nan.txt - https://www.assembla.com/spaces/clojure/documents/bSLft0zyGr35jbeJe5cbLr/download/bSLft0zyGr35jbeJe5cbLr