• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
        • Program-execution
        • Sdm-instruction-set-summary
        • Tlb
        • Running-linux
        • Introduction
        • Asmtest
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
          • X86isa-state
          • Syscalls
          • Cpuid
          • Linear-memory
          • Rflag-specifications
          • Characterizing-undefined-behavior
          • Top-level-memory
          • App-view
          • X86-decoder
          • Physical-memory
          • Decoding-and-spec-utils
          • Instructions
            • Two-byte-opcodes
            • One-byte-opcodes
            • Fp-opcodes
            • Instruction-semantic-functions
              • Sar-spec
              • Shr-spec
              • Sal/shl-spec
              • Rol-spec
              • Ror-spec
              • Rcl-spec
              • Rcr-spec
              • Simd-sub-spec
              • Simd-add-spec
              • Imul-spec
              • Mul-spec
              • Idiv-spec
              • Div-spec
              • Shrd-spec
              • Shld-spec
              • Gpr-arith/logic-spec
              • Shrx-spec
              • Shlx-spec
              • Sarx-spec
              • Floating-point-specifications
                • Floating-point-converts
                • Floating-point-arithmetic-specifications
                • Basic-floating-point-utilities
                  • Fp-decode
                  • Make-special-bp
                  • Fp-round-overflow-generic
                  • Fp-to-rat
                    • Fp-encode-integer
                    • Sse-daz
                    • Denormal-exception
                    • Convert-rc-to-mode
                  • Floating-point-comparison-specifications
              • X86-illegal-instruction
              • Implemented-opcodes
              • Opcode-maps
              • X86-general-protection
              • X86-device-not-available
              • X86-step-unimplemented
              • Privileged-opcodes
              • Three-byte-opcodes
            • Register-readers-and-writers
            • X86-modes
            • Segmentation
            • Other-non-deterministic-computations
            • Environment
            • Paging
          • Implemented-opcodes
          • To-do
          • Proof-utilities
          • Peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Basic-floating-point-utilities

    Fp-to-rat

    Convert the bit-vector or integer representation used by hardware to rational for the cases of zero, denormal, and normal.

    Signature
    (fp-to-rat sign exp frac bias exp-width frac-width) → *
    Arguments
    sign — Guard (integerp sign).
    exp — Guard (integerp exp).
    frac — Guard (integerp frac).
    bias — Guard (natp bias).
    exp-width — Guard (posp exp-width).
    frac-width — Guard (posp frac-width).

    Definitions and Theorems

    Function: fp-to-rat

    (defun fp-to-rat (sign exp frac bias exp-width frac-width)
      (declare (xargs :guard (and (integerp sign)
                                  (integerp exp)
                                  (integerp frac)
                                  (natp bias)
                                  (posp exp-width)
                                  (posp frac-width))))
      (let ((__function__ 'fp-to-rat))
        (declare (ignorable __function__))
        (cond ((and (eql exp 0) (eql frac 0)) 0)
              ((and (eql exp 0) (not (eql frac 0)))
               (let ((man (* frac (expt 2 (- frac-width)))))
                 (* (if (eql sign 0) 1 -1)
                    man (expt 2 (- 1 bias)))))
              ((and (< 0 exp)
                    (<= exp (fp-max-finite-exp exp-width)))
               (let ((man (* (logior (ash 1 frac-width) frac)
                             (expt 2 (- frac-width)))))
                 (* (if (eql sign 0) 1 -1)
                    man (expt 2 (- exp bias)))))
              (t 0))))

    Theorem: rationalp-fp-to-rat

    (defthm rationalp-fp-to-rat
      (implies
           (integerp frac)
           (rationalp (fp-to-rat sign
                                 exp frac bias exp-width frac-width)))
      :rule-classes :type-prescription)