#elisp
It is sometimes convenient to use eq
for comparing
an unknown value with an integer, because eq
does not report an
error if the unknown value is not a number—it accepts arguments of
any type. By contrast, =
signals an error if the arguments are
not numbers or markers. However, it is better programming practice to
use =
if you can, even for comparing integers
If you want to change selection, open document below and click on "Move attachment"
GNU Emacs Lisp Reference Manual: Comparison of Numbersen you test whether two values are the same
object. By contrast, = compares only the numeric values
of the objects.
In Emacs Lisp, each integer is a unique Lisp object.
Therefore, eq is equivalent to = where integers are
concerned. <span>It is sometimes convenient to use eq for comparing
an unknown value with an integer, because eq does not report an
error if the unknown value is not a number—it accepts arguments of
any type. By contrast, = signals an error if the arguments are
not numbers or markers. However, it is better programming practice to
use = if you can, even for comparing integers.
Sometimes it is useful to compare numbers with equal , which
treats two numbers as equal if they have the same data type (both
integers, or both floating point) and the same value. Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details