<= 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:
Alex Miller
April 25, 2014, 2:22 AM

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

Jason Wolfe
April 24, 2014, 11:19 PM

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 24, 2014, 9:22 PM

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

Andy Fingerhut
April 18, 2014, 5:41 PM

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.

Andy Fingerhut
March 5, 2014, 6:32 PM

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

Completed
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Unassigned

Reporter

Jason Wolfe

Labels

Approval

Ok

Patch

Code and Test

Priority

Trivial

Affects versions

Fix versions