Uploaded image for project: 'Clojure'
  1. CLJ-354

<= and >= comparisons against NaN return true

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: Backlog
    • 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>.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: