Clojure

<= and >= comparisons against NaN return true

Details

  • Type: Defect Defect
  • Status: Closed 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>.

Activity

No changes have yet been made on this issue.

People

  • Assignee:
    Unassigned
    Reporter:
    Anonymous
Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: