• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
          • Character-listp
          • Characterp
          • Coerce
          • Digit-char-p
          • Code-char
          • Char-code
          • Char-upcase
          • Char-downcase
          • Standard-char-p
          • Char
          • Alpha-char-p
          • Upper-case-p
          • Lower-case-p
          • Explode-nonnegative-integer
            • Explode-atom
            • Char-equal
            • Digit-to-char
            • Char<
            • Char>=
            • Make-character-list
            • Char>
            • Char<=
            • Standard-char-listp
            • Character-alistp
            • Standard-char-p+
            • Chars-upcase-gen
            • Chars-downcase-gen
            • Char-upcase-gen
            • Char-downcase-gen
          • Time$
          • Defmacro
          • Loop$-primer
          • Fast-alists
          • Defconst
          • Evaluation
          • Guard
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • Developers-guide
          • System-attachments
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Efficiency
          • Irrelevant-formals
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Characters
    • Numbers
    • ACL2-built-ins

    Explode-nonnegative-integer

    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 n, (explode-nonnegative-integer n r nil) is the list of characters in the radix-r (base-r) representation of n.

    The guard for explode-nonnegative-integer requires the first argument to be a nonnegative integer and second argument to be a valid radix for ACL2 (2, 8, 10, or 16).

    See also explode-atom, str::numbers, and printing-to-strings.

    Function: explode-nonnegative-integer

    (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)))))