Microfloats is a Julia package that implements types and arithmetic (through wider intermediates) for sub-byte floating points, supporting arbitrary combinations of sign, exponent, and significand (mantissa) bits.
Instances of a sub-8 bit floating point type are still one byte wide in memory; Microfloats serves as a base for method dispatch and a reference for arithmetic operations, lending downstream packages a foundation for bitpacking and hardware acceleration.
Define your own primitive type with the macro:
using Microfloats
@microfloat MyE5M2 sign=1 exponent=5 significand=2 nonfinite=Microfloats.IEEEor see the documentation for a list of predefined types.
using Pkg
Pkg.add("Microfloats")