summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/objects.texi7
-rw-r--r--lisp/subr.el9
-rw-r--r--src/data.c21
3 files changed, 13 insertions, 24 deletions
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index 8c92de123c2..a0940032eee 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -190,9 +190,10 @@ but many machines provide a wider range.
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
diff --git a/lisp/subr.el b/lisp/subr.el
index cafa4835eaf..9e880bc880e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -366,6 +366,15 @@ was called."
(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.
diff --git a/src/data.c b/src/data.c
index 4c6d33f2940..08c7271dd79 100644
--- a/src/data.c
+++ b/src/data.c
@@ -511,16 +511,6 @@ DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0,
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)
@@ -598,15 +588,6 @@ DEFUN ("condition-variable-p", Fcondition_variable_p, Scondition_variable_p,
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;
-}
/* Extract and set components of lists. */
@@ -4153,7 +4134,6 @@ syms_of_data (void)
defsubr (&Sconsp);
defsubr (&Satom);
defsubr (&Sintegerp);
- defsubr (&Sfixnump);
defsubr (&Sinteger_or_marker_p);
defsubr (&Snumberp);
defsubr (&Snumber_or_marker_p);
@@ -4179,7 +4159,6 @@ syms_of_data (void)
defsubr (&Sthreadp);
defsubr (&Smutexp);
defsubr (&Scondition_variable_p);
- defsubr (&Sbignump);
defsubr (&Scar);
defsubr (&Scdr);
defsubr (&Scar_safe);