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

<= is incorrect when args include Double/NaN

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Completed
    • Affects versions: Release 1.6
    • Fix versions: Release 1.7
    • Labels:
    • Environment:

      Mac OS X, Java 6

    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      user=> (<= Double/NaN 1)
      false  
      user=> (<= (double Double/NaN) 1)
      true    ;; should match Double object result
      

      Cause: The problem was that the logic for lte/gte depended on the fact that lte is equivalent to !gt.
      However, in Java, this assumption is invalid - any comparison involving NaN always yields false.

      Solution: The fix was to adding lte and gte methods to Numbers.Ops directly, rather than implementing everything in terms of lt. This was the only fix I could see that didn't incur the cost of runtime checks for NaN.

      Patch: clj-738-v2.diff

      Screened by: Alex Miller

        Attachments

        1. clj-738-v2.diff
          6 kB
        2. 738-tests.diff
          3 kB
        3. 738.diff
          4 kB

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jawolfe Jason Wolfe
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: