Elisp: Compare Numbers, Equality

By Xah Lee. Date: . Last updated: .

Number Equality Test

=

Check if numbers are equal.

Numbers can be a integer and a float.

(= 3 3)
;; t

(= 3.8 3.8)
;; t

;; can compare between int and float
(= 3 3.0)
;; t
;; warning: float problems
(= 3 3.0000000000000001)
;; t
(= 3 3.000000000000001)
;; nil
;; not equal
(/= 3 4) ; t
/=

compare two numbers are unequal

(/= 3 4)
;; t

;; can be used on int and float
(/= 3 3.0)
;; nil

Compare Number Order

;; less than
(< 3 4)
;; t

;; greater than
(> 3 4)
;; nil
;; less or equal
(<= 3 4)
;; t

;; greater or equal
(>= 3 4)
;; nil

Emacs Lisp, Numbers

Emacs Lisp, Boolean