The MicroFloatingPoints package defines the Floatmu
parametric type to manipulate IEEE 754 standard-compliant floating-point numbers with a very small size (from 5 bits up to 32 bits).
Adding 0.25
and 2.0
in a floating-point format with 1 bit for the sign (implied), 2 bits for the exponent, and 2 bits for the fractional part (3 bits for the whole significand with the hidden bit), and testing whether the result had to be rounded:
julia> using MicroFloatingPoints
julia> Floatmu{2,2}(0.25)+Floatmu{2,2}(2.0)
2.0
julia> inexact()
true
The package can be installed with the Julia package manager. From the Julia REPL, type ]
to enter the Pkg REPL mode and run:
pkg> add MicroFloatingPoints
Or, equivalently, via the Pkg API:
julia> import Pkg; Pkg.add("MicroFloatingPoints")
Optionally, to enable plotting, install either one of PyPlot.jl or PythonPlot.jl as follows.
julia> import Pkg; Pkg.add("PyPlot")
OR
julia> import Pkg; Pkg.add("PythonPlot")
Note that the matplotlib
Python package must be available through PyCall
or PythonCall
.
This is usually setup when installing PyPlot.jl
or PythonPlot.jl, which are optional (weak) dependencies
that provide plotting backends via package extensions.
The package is developed and has been tested on Julia 1.6 through 1.10.