• 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
        • 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
          • Std/strings
          • String-listp
          • Stringp
          • Length
          • Search
          • Remove-duplicates
          • Position
          • Coerce
          • Concatenate
          • Reverse
          • String
          • Subseq
          • Substitute
          • String-upcase
          • String-downcase
          • Count
          • Char
          • String<
          • String-equal
          • String-utilities
            • Code-char-injectivity-theorem
            • 8bitbytes-hexchars-conversions
              • Ubyte8s=>hexchars
              • Hexchars=>ubyte8s
              • Ubyte8=>hexchars
              • Hexchars=>ubyte8
                • Ubyte8<=>hexchars-inverses-theorems
            • Code-char-inverses-theorems
            • String-kinds
            • String-codelist-conversions
            • Charlist-codelist-conversions
            • 8bitbytes-hexstrings-conversions
          • String-append
          • String>=
          • String<=
          • String>
          • Hex-digit-char-theorems
          • String-downcase-gen
          • String-upcase-gen
        • 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
  • 8bitbytes-hexchars-conversions

Hexchars=>ubyte8

Convert two hexadecimal digit characters to an unsigned 8-bit byte.

Signature
(hexchars=>ubyte8 hi-char lo-char) → byte
Arguments
hi-char — Guard (str::hex-digit-char-p hi-char).
lo-char — Guard (str::hex-digit-char-p lo-char).
Returns
byte — Type (unsigned-byte-p 8 byte).

The most significant digit comes first, followed by the least significant one.

Definitions and Theorems

Function: hexchars=>ubyte8

(defun hexchars=>ubyte8 (hi-char lo-char)
  (declare (xargs :guard (and (str::hex-digit-char-p hi-char)
                              (str::hex-digit-char-p lo-char))))
  (let ((__function__ 'hexchars=>ubyte8))
    (declare (ignorable __function__))
    (b* ((hi-digit (str::hex-digit-char-value hi-char))
         (lo-digit (str::hex-digit-char-value lo-char)))
      (+ (* 16 hi-digit) lo-digit))))

Theorem: return-type-of-hexchars=>ubyte8

(defthm return-type-of-hexchars=>ubyte8
  (b* ((byte (hexchars=>ubyte8 hi-char lo-char)))
    (unsigned-byte-p 8 byte))
  :rule-classes :rewrite)

Subtopics

Ubyte8<=>hexchars-inverses-theorems
ubyte8=>hexchars and hexchars=>ubyte8 are mutual inverses.