Microfloats

May 29, 2026 ยท View on GitHub

Stable Dev Build Status Coverage

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 like cuTile.jl a useful layer of abstraction.

Usage

Define your own primitive type with the macro:

using Microfloats

@microfloat MyE5M2 sign=1 exponent=5 significand=2 nonfinite=Microfloats.IEEE

or see the documentation for a list of predefined types.

Installation

using Pkg
Pkg.add("Microfloats")

See also