Documentation

Init.Data.Float.Model.Format.Basic

def Float.Model.totalExponent (mantissa : Nat) (exponent : Int) :

The position of the most significant digit, where the unit digit corresponds to 1. So, for example, 1.0b has total exponent 1, 0.1b has total exponent 0, 0.01b has total exponent -1, and so on.

Equations
Instances For

    A floating point format is specified by two pieces of information: the number of bits in the mantissa, and the number of bits in the exponent.

    Instances For
      @[reducible, inline]

      Specification corresponding to the IEEE binary32 format.

      Equations
      Instances For
        @[reducible, inline]

        Specification corresponding to the IEEE binary64 format.

        Equations
        Instances For
          @[reducible, inline]

          The total number of bits in the packed representation.

          Equations
          Instances For

            The number of bits in the mantissa, including the implicit bit.

            Equations
            Instances For

              The exponent bias. In packed formats, we store the sum of the true exponent and the bias.

              Equations
              Instances For

                The smallest exponent possible for a number using the given specification, including subnormals.

                Equations
                Instances For
                  def Float.Model.Format.targetExponent (spec : Format) (totalExponent : Int) :

                  Suppose we have written a number where totalExponent is the position of the most significant digit, where the unit digit corresponds to 1. So, for example, 1.0b has total exponent 1, 0.1b has total exponent 0, 0.01b has total exponent -1, and so on. This function computes which exponent that number should have according to the given Format. So, for example, for the number 0.1b in binary64 format, it wants us to use the exponent -53, corresponding to the representation 2^52 * 2^(-53), which has a 53-bit mantissa. If the total exponent gets quite small, then the result exponent eventually gets capped at spec.minExponent, which first forces the result to be a subnormal number and then, if the total exponent is even smaller, to be zero.

                  Equations
                  Instances For