Recognizer for natural numbers that fit in a specified bit width
(Unsigned-byte-p bits x) is T when bits is a
positive integer and x is a nonnegative integer that fits into a
bit-width of bits, i.e., 0 <= x < 2^bits.
Note that a type-spec of (unsigned-byte i) for a variable
x in a function's declare form translates to a guard
condition of (unsigned-byte-p i x).
The guard for unsigned-byte-p is T.
(defun unsigned-byte-p (bits x)
(declare (xargs :guard t))
(and (integerp bits)
(<= 0 bits)
(integer-range-p 0 (expt 2 bits) x)))