<= is incorrect when args include Double/NaN

Description

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

Environment

Mac OS X, Java 6

Activity

Show:
Andy Fingerhut
March 6, 2014, 5:32 AM

Might want to make the "Fix Version" on this ticket empty so it is back on the JIRA state chart as Vetted.

Andy Fingerhut
April 19, 2014, 3:41 AM

Patch clj-738-v2.diff is identical in content to Luke's 2 patches 738.diff and 738-tests.diff, and includes them both, retaining his authorship. The only change is to a few context lines so that the new patch applies cleanly to latest master, whereas the older patches did not.

Alex Miller
April 25, 2014, 7:22 AM

While the patch looks good and tests all pass, the example listed in the ticket description did not actually change behavior with the patch?

Jason Wolfe
April 25, 2014, 9:19 AM

The ticket description has a typo (long, not double) – sorry. The first comment has a real test case.

user> (<= 1000 (Double. Double/NaN))
true
user> (<= 1000 (double Double/NaN))
false

Alex Miller
April 25, 2014, 12:22 PM

Doh! Thank you. I'm the one that introduced it too.

Completed

Assignee

Unassigned

Reporter

Jason Wolfe

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Affects versions

Priority

Trivial