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
- Float.Model.totalExponent mantissa exponent = ↑mantissa.log2 + 1 + exponent
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.
- mantissaBitsWithoutImplicit : Nat
The number of bits in the mantissa, excluding the implicit bit.
- exponentBits : Nat
The number of bits in the exponent.
Instances For
Specification corresponding to the IEEE binary32 format.
Equations
- Float.Model.Format.binary32 = { mantissaBitsWithoutImplicit := 23, hm := Float.Model.Format.binary32._proof_1, exponentBits := 8, he := Float.Model.Format.binary32._proof_2 }
Instances For
Specification corresponding to the IEEE binary64 format.
Equations
- Float.Model.Format.binary64 = { mantissaBitsWithoutImplicit := 52, hm := Float.Model.Format.binary64._proof_1, exponentBits := 11, he := Float.Model.Format.binary64._proof_2 }
Instances For
The total number of bits in the packed representation.
Equations
- spec.numBits = 1 + spec.exponentBits + spec.mantissaBitsWithoutImplicit
Instances For
The number of bits in the mantissa, including the implicit bit.
Equations
- spec.mantissaBits = 1 + spec.mantissaBitsWithoutImplicit
Instances For
The exponent bias. In packed formats, we store the sum of the true exponent and the bias.
Equations
- spec.exponentBias = 2 ^ (spec.exponentBits - 1) - 1
Instances For
The smallest exponent possible for a number using the given specification, including subnormals.
Equations
- spec.minExponent = 3 - 2 ^ (spec.exponentBits - 1) - ↑spec.mantissaBits
Instances For
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
- spec.targetExponent totalExponent = max (totalExponent - ↑spec.mantissaBits) spec.minExponent