• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
      • X86isa
      • Svl
      • 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
      • Software-verification
      • Math
      • Testing-utilities
    • Floating-Point Formats

    Infinities and NaNs

    Infinities and NaNs

    Definitions and Theorems

    Function: infp

    (defun infp (x f)
      (declare (xargs :guard (encodingp x f)))
      (and (mbt (encodingp x f))
           (= (expf x f) (1- (expt 2 (expw f))))
           (not (unsupp x f))
           (= (manf x f) 0)))

    Function: iencode

    (defun iencode (sgn f)
      (declare (xargs :guard (and (bvecp sgn 1) (formatp f))))
      (if (explicitp f)
          (cat sgn 1 (1- (expt 2 (expw f)))
               (expw f)
               1 1 0 (1- (sigw f)))
        (cat sgn 1 (1- (expt 2 (expw f)))
             (expw f)
             0 (sigw f))))

    Function: nanp

    (defun nanp (x f)
      (declare (xargs :guard (encodingp x f)))
      (and (mbt (encodingp x f))
           (= (expf x f) (1- (expt 2 (expw f))))
           (not (unsupp x f))
           (not (= (manf x f) 0))))

    Function: qnanp

    (defun qnanp (x f)
      (declare (xargs :guard (encodingp x f)))
      (and (nanp x f)
           (= (bitn x (- (prec f) 2)) 1)))

    Function: snanp

    (defun snanp (x f)
      (declare (xargs :guard (encodingp x f)))
      (and (nanp x f)
           (= (bitn x (- (prec f) 2)) 0)))

    Function: qnanize

    (defun qnanize (x f)
      (declare (xargs :guard (encodingp x f)))
      (logior x (expt 2 (- (prec f) 2))))

    Function: indef

    (defun indef (f)
      (declare (xargs :guard (formatp f)))
      (if (explicitp f)
          (cat (1- (expt 2 (+ (expw f) 2)))
               (+ (expw f) 2)
               0 (- (sigw f) 2))
        (cat (1- (expt 2 (+ (expw f) 1)))
             (+ (expw f) 1)
             0 (1- (sigw f)))))