Proper way to compare numbers in Clojure

less than 1 minute read

Code

;; number_comparison_right_way.clj

(= 7 7)

(= 7 7.0)

(type 7)

(type 7.0)

(= 7 7N)

(type 7N)

(= 7.0 7N)

(type 7M)

(= 7.0 7M)

(= 7 7M)

(= (double 7) 7.0)

(== 7 7.0)

(== 7 7.0M)

(== 7.0 7M)

(== Math/PI (/ 22 7 ))

(== 7N 7M 7 7.0)

(= 7N 7M 7 7.0)

Notes

Updated: