Skip to content

Universal Number Systems Guide

This directory contains comprehensive documentation for each number system in the Universal library. Each document explains why the number system exists, what it does, and how to use it to solve specific problems.

TypeBitsDescriptionBest For
integerNArbitrary-width signed integerCryptography, combinatorics, wide counters
fixpntNBinary fixed-point with configurable radixDSP, control systems, embedded (no FPU)
dfixpntNDecimal fixed-point with configurable radixFinancial ledgers, COBOL migration, tax/POS
rational2NExact numerator/denominator fractionSymbolic math, exact geometry, financial
TypeBitsDescriptionBest For
cfloat4-256Fully parameterized IEEE-compatible floatMixed-precision research, custom HW design
bfloat1616Google Brain Float (8-bit exponent, 7-bit fraction)Neural network training, TPU workloads
arealNFaithful float with uncertainty bitVerified computing, uncertainty tracking
dfloatNDecimal floating-point (base-10)Financial systems, regulatory compliance
hfloatNHexadecimal floating-point (IBM System/360)Legacy mainframe validation, data archaeology

Micro-Precision and Block-Scaled (AI Quantization)

Section titled “Micro-Precision and Block-Scaled (AI Quantization)”
TypeBitsDescriptionBest For
microfloat4-8OCP MX element types (e2m1, e4m3, e5m2)AI model elements, quantization validation
e8m08Exponent-only power-of-two scaleBlock scale factor for MX format
mxfloatBlockOCP Microscaling block formatAI inference, model compression (OCP)
nvblockBlockNVIDIA NVFP4 block formatGPU inference, NVIDIA accelerators
TypeBitsDescriptionBest For
positNTapered-precision floating-point (current v2)General numeric, more precision than IEEE
posit1NOriginal posit implementation (legacy v1)Backward compatibility
positoNExperimental posit variantDifferential testing, research
takumNBounded-range tapered floatGeneral computing, predictable range
TypeBitsDescriptionBest For
quireWideGeneralized super-accumulator for exact dot productsReproducible linear algebra, BLAS

The quire is a number-system-agnostic accumulator that provides exact dot products for cfloat, posit, fixpnt, lns, dbns, integer, native float, and native double.

TypeBitsDescriptionBest For
valid2NInterval arithmetic with posit-encoded boundsVerified computing with posit precision
interval2NGeneric interval over any scalar typeTolerance analysis, uncertainty propagation
sornNSet of operand range numbersRigorous uncertainty, safety-critical bounds
unum2NConfigurable exact-value latticeResearch, custom value distributions
TypeBitsDescriptionBest For
lnsNSingle-base logarithmic (base 2)DSP, multiply-heavy workloads, low-power HW
dbnsNDouble-base logarithmic (base 0.5 and 3)Research, mixed-radix applications
TypeBitsDecimal DigitsDescriptionBest For
dd128~31Double-double (2 doubles)Extended precision, ill-conditioned systems
qd256~64Quad-double (4 doubles)Ultra-high precision, constant computation
dd_cascade128~31DD via unified cascade frameworkConsistent API across precision tiers
td_cascade192~48Triple-double (3 doubles)Intermediate precision tier
qd_cascade256~64QD via unified cascade frameworkConsistent API across precision tiers
TypeDescriptionBest For
eintegerAdaptive-precision integerCryptography, arbitrary-width counters
edecimalAdaptive-precision decimalExact decimal arithmetic
erationalAdaptive-precision rationalSymbolic math, exact fractions
efloatAdaptive-precision multi-digit floatVariable-precision scientific computing
erealAdaptive-precision multi-component realHighest-precision computation
TypeDescriptionBest For
zfpblockZFP block-based float compression (1D/2D/3D)Scientific data storage, simulation checkpoints
TypeDescriptionBest For
complexComplex arithmetic for any Universal scalarFFT, signal processing, quantum computing
DomainRecommended Types
Deep Learning Inferencemicrofloat, mxfloat, nvblock, bfloat16, cfloat(fp8)
Deep Learning Trainingbfloat16, cfloat(fp16/fp32), posit
DSP / Signal Processingfixpnt, lns, complex
Financial / Accountingdfixpnt, dfloat, rational, fixpnt
Embedded (no FPU)fixpnt, integer
Scientific HPCdd, qd, posit, cfloat
Verified / Validated Computinginterval, valid, areal, sorn
Reproducible Linear Algebraany type + quire (cfloat, posit, fixpnt, lns, float, double)
Cryptography / Big Numbersinteger
Data Compressionzfpblock
Custom Hardware Designcfloat, posit, takum, lns
PrecisionTypeDecimal Digits
2 digitsbfloat16~2
3 digitscfloat(fp8), microfloat~2-3
7 digitscfloat(fp32), posit<32,2>~7-8
16 digitscfloat(fp64), double~16
31 digitsdd, dd_cascade~31
48 digitstd_cascade~48
64 digitsqd, qd_cascade~64
Exact (decimal)dfixpntConfigurable (ndigits)
Exactrational, integer, quireUnlimited (within nbits)

Every number system is header-only. Include the type and start computing:

#include <universal/number/posit/posit.hpp> // or any type
using namespace sw::universal;
// Plug-in replacement pattern
template<typename Real>
Real my_algorithm(Real a, Real b) {
return (a + b) * (a - b);
}
// Use with any Universal type
auto r1 = my_algorithm(posit<32,2>(3.0), posit<32,2>(4.0));
auto r2 = my_algorithm(cfloat<16,5,uint16_t,true,false,false>(3.0),
cfloat<16,5,uint16_t,true,false,false>(4.0));
auto r3 = my_algorithm(dd(3.0), dd(4.0));

For detailed usage patterns, see the api/api.cpp test file in each number system’s regression test directory under static/.