The list of characters in the radix-r form of a number
Examples: ACL2 !>(explode-nonnegative-integer 925 10 nil) (#9 #2 #5) ACL2 !>(explode-nonnegative-integer 325 16 nil) (#3 #9 #D)
For a non-negative integer
The guard for
See also explode-atom, str::numbers, and printing-to-strings.
Function:
(defun explode-nonnegative-integer (n print-base ans) (declare (xargs :guard (and (integerp n) (>= n 0) (print-base-p print-base)))) (cond ((or (zp n) (not (print-base-p print-base))) (cond ((null ans) '(#\0)) (t ans))) (t (explode-nonnegative-integer (floor n print-base) print-base (cons (digit-to-char (mod n print-base)) ans)))))