ClojureDocs

Nav

Namespaces

NaN?

clojure.core

Available since 1.11 (source)
  • (NaN? num)
Returns true if num is NaN, else false
1 Example
(NaN? (Math/sqrt -1))
;; => true

(NaN? (* ##Inf 0))
;; => true

(NaN? (clojure.math/asin 2))
;; => true

(NaN? (clojure.math/acos -2))
;; => true

(NaN? (- ##Inf ##Inf))
;; => true

(NaN? (clojure.math/log -1))
;; => true

;; Note, NaN is, somewhat confusingly, a property only of numbers (floats and doubles)
;; So even though a string is "not a number" it is not ##NaN…
(NaN? "a string")
;; => : java.lang.String cannot be cast to java.lang.Number…

;; You'll want to use `number?` for that…
(def actually-not-a-number? (complement number?))
(actually-not-a-number? "string")
;; => true

;; But remember…
(actually-not-a-number? ##NaN)
;; => false
See Also

Same as (not (= obj1 obj2))

Added by tomdl89
0 Notes
No notes for NaN?