Comparing NaNs to numbers: (<= NaN x) should be false

2 views
Skip to first unread message

Jouni K. Seppänen

unread,
Apr 4, 2010, 10:39:14 AM4/4/10
to Clojure
This is with Clojure 1.1.0:

user=> (< Float/NaN 1.0)
false
user=> (<= Float/NaN 1.0)
true

Both comparisons should yield false. It seems that (<= x y) is
implemented by negating the result of (< y x), which is fine for
totally-ordered sets, but unfortunately IEEE 754 floating-point
numbers do not form such a set. (See e.g. Java Language Specification
§15.20.1).

Reply all
Reply to author
Forward
0 new messages