• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
      • 100-theorems
      • Arithmetic
      • Bit-vectors
        • Sparseint
        • Bitops
        • Bv
        • Ihs
        • Rtl
          • Floating-Point Exceptions and Specification of Elementary Arithmetic Instructions
          • Implementation of Elementary Operations
          • Register-Transfer Logic
          • Floating-Point Arithmetic
            • Rounding
            • Floating-Point Formats
              • Normal Encodings
              • Denormals and Zeroes
              • Classification of Formats
                • Rebiasing Exponents
                • Infinities and NaNs
              • Floating-Point Numbers
            • Modeling Algorithms in C++ and ACL2
            • Bibliography
        • Algebra
      • Testing-utilities
    • Floating-Point Formats

    Classification of Formats

    Classification of Formats

    Definitions and Theorems

    Function: formatp

    (defun formatp (f)
      (declare (xargs :guard t))
      (and (consp f)
           (consp (cdr f))
           (consp (cddr f))
           (natp (cadr f))
           (> (cadr f) 1)
           (natp (caddr f))
           (> (caddr f) 1)))

    Function: explicitp

    (defun explicitp (f)
      (declare (xargs :guard (formatp f)))
      (car f))

    Function: prec

    (defun prec (f)
      (declare (xargs :guard (formatp f)))
      (cadr f))

    Function: expw

    (defun expw (f)
      (declare (xargs :guard (formatp f)))
      (caddr f))

    Function: sigw

    (defun sigw (f)
      (declare (xargs :guard (formatp f)))
      (if (explicitp f)
          (prec f)
        (1- (prec f))))

    Function: encodingp

    (defun encodingp (x f)
      (declare (xargs :guard t))
      (and (formatp f)
           (bvecp x (+ 1 (expw f) (sigw f)))))

    Function: hp

    (defun hp nil
      (declare (xargs :guard t))
      '(nil 11 5))

    Function: sp

    (defun sp nil
      (declare (xargs :guard t))
      '(nil 24 8))

    Function: dp

    (defun dp nil
      (declare (xargs :guard t))
      '(nil 53 11))

    Function: bf

    (defun bf nil
      (declare (xargs :guard t))
      '(nil 8 8))

    Function: ep

    (defun ep nil
      (declare (xargs :guard t))
      '(t 64 15))

    Theorem: formatp-sp

    (defthm formatp-sp (formatp (sp)))

    Theorem: formatp-dp

    (defthm formatp-dp (formatp (dp)))

    Theorem: formatp-hp

    (defthm formatp-hp (formatp (hp)))

    Theorem: formatp-ep

    (defthm formatp-ep (formatp (ep)))

    Function: sgnf

    (defun sgnf (x f)
      (declare (xargs :guard (encodingp x f)))
      (bitn x (+ (expw f) (sigw f))))

    Function: expf

    (defun expf (x f)
      (declare (xargs :guard (encodingp x f)))
      (bits x (1- (+ (expw f) (sigw f)))
            (sigw f)))

    Function: sigf

    (defun sigf (x f)
      (declare (xargs :guard (encodingp x f)))
      (bits x (1- (sigw f)) 0))

    Function: manf

    (defun manf (x f)
      (declare (xargs :guard (encodingp x f)))
      (bits x (- (prec f) 2) 0))

    Function: bias

    (defun bias (f)
      (declare (xargs :guard (formatp f)))
      (- (expt 2 (- (expw f) 1)) 1))