fixnum will return a bignum instead.
Fixnums can be compared with @code{eq}, but bignums require
-@code{eql} or @code{=}. The @code{fixnump} predicate can be used to
-detect such small integers, and @code{bignump} can be used to detect
-large integers.
+@code{eql} or @code{=}. To test whether an integer is a fixnum or a
+bignum, you can compare it to @code{most-negative-fixnum} and
+@code{most-positive-fixnum}, or you can use the convenience predicates
+@code{fixnump} and @code{bignump} on any object.
The read syntax for integers is a sequence of (base ten) digits with an
optional sign at the beginning and an optional period at the end. The
(declare (compiler-macro (lambda (_) `(= 0 ,number))))
(= 0 number))
+(defun fixnump (object)
+ "Return t if OBJECT is a fixnum."
+ (and (integerp object)
+ (<= most-negative-fixnum object most-positive-fixnum)))
+
+(defun bignump (object)
+ "Return t if OBJECT is a bignum."
+ (and (integerp object) (not (fixnump object))))
+
(defun lsh (value count)
"Return VALUE with its bits shifted left by COUNT.
If COUNT is negative, shifting is actually to the right.
return Qnil;
}
-DEFUN ("fixnump", Ffixnump, Sfixnump, 1, 1, 0,
- doc: /* Return t if OBJECT is an fixnum. */
- attributes: const)
- (Lisp_Object object)
-{
- if (FIXNUMP (object))
- return Qt;
- return Qnil;
-}
-
DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0,
doc: /* Return t if OBJECT is an integer or a marker (editor pointer). */)
(register Lisp_Object object)
return Qt;
return Qnil;
}
-
-DEFUN ("bignump", Fbignump, Sbignump, 1, 1, 0,
- doc: /* Return t if OBJECT is a bignum. */)
- (Lisp_Object object)
-{
- if (BIGNUMP (object))
- return Qt;
- return Qnil;
-}
\f
/* Extract and set components of lists. */
defsubr (&Sconsp);
defsubr (&Satom);
defsubr (&Sintegerp);
- defsubr (&Sfixnump);
defsubr (&Sinteger_or_marker_p);
defsubr (&Snumberp);
defsubr (&Snumber_or_marker_p);
defsubr (&Sthreadp);
defsubr (&Smutexp);
defsubr (&Scondition_variable_p);
- defsubr (&Sbignump);
defsubr (&Scar);
defsubr (&Scdr);
defsubr (&Scar_safe);