Developer Documentation

This part is intended for developers who intend to extend or maintain the package.

Work In Progress

This part is a work in progress and should be expanded in the next revisions.

Construction of a Floatmu

The Floatmu type has two constructors that create a float directly from its integer representation.

Floatmu{szE,szf}(x::UInt32, dummy) where {szE,szf}
Floatmu{szE,szf}(x::Tuple{UInt32,Int64}, dummy) where {szE,szf}

The first constructor uses x as the internal representation of the float, assuming no rounding occurred; the second constructor uses the UInt32 element of the tuple as the internal representation , while the Int64 element correspond to the sign of the error if some rounding took place to generate the float.

For both constructors, dummy may be anything and serves only to avoid ambiguities when calling a constructor. It is customary to use nothing for this parameter and the code of the package always does.

MicroFloatingPoints.nb_fp_numbersMethod
nb_fp_numbers(a::Floatmu{szE,szf}, b::Floatmu{szE,szf}) where {szE,szf}

Return the number of floats in the interval $[a,b]$. If $a > b$, throw an ArgumentError exception.

Examples

julia> nb_fp_numbers(Floatmu{2, 2}(-0.0),Floatmu{2, 2}(0.0))
1
julia> nb_fp_numbers(Floatmu{2, 2}(3.0),Floatmu{2, 2}(3.5))
2
source
MicroFloatingPoints.roundfracMethod
roundfrac(f,szf)

Round to nearest-even a 52 bits fractional part to szf bits Return a triplet composed of the rounded fractional part, a correction to the exponent if a bit from the fractional part spilled into the integer part, and a rounding direction (by default: -1, by excess: 1, no rounding: 0) if some rounding had to take place.

source
MicroFloatingPoints.float64_to_uint32muMethod
float64_to_uint32mu(x::Float64,szE,szf)

Round x to the precision of a Floatmu{szE,szf} and return a pair composed of the bits representation right-aligned in a UInt32 together with a rounding direction if rounding took place (by default: -1, by excess: 1, no rounding: 0).

source

Iterators

MicroFloatingPoints.check_eligibility_stepMethod
check_eligibility_step(start::Floatmu{szE,szf}, stop::Floatmu{szE,szf},
                       step::Floatmu{szE,szf}) where {szE,szf}

Check whether the step step can be reliability used for the domain [start, stop]. Throw an ArgumentError exception in the negative.

source

The MicroFloatingPoints.MFPRandom module

MicroFloatingPoints.MFPRandom.irandintMethod
irandint(rng::Random.AbstractRNG, n::Int64)

Draw a n bits integer at random.

First, compute a 64 bits integer, then discard the lowest (64-n) bits, which are often the less random ones.

Throw an ArgumentError exception if n is strictly greater than 64.

source

Examples

julia> MicroFloatingPoints.MFPRandom.irandint(Random.MersenneTwister(42),23)