Published March 14, 2023 | Version v3.68
Software Open

Universal Numbers Library: Multi-format Variable Precision Arithmetic Library

  • 1. Stillwater Supercomputing, Inc.
  • 2. School of Mathematics and Physical Sciences, University of New England

Description

Universal Numbers Library, or simply Universal, is a comprehensive, self-contained C++ header-only template library that provides implementations of various number representations and standard arithmetic operations on arbitrary configurations of integer and real numbers. With its extensive collection of number systems, including integers, decimals, fixed-points, rationals, linear floats, tapered floats, logarithmic, SORNs, interval, level-index, and adaptive-precision binary and decimal integers and floats, Universal offers a robust verification suite for each system.

The primary pattern using a posit number type as example is:

#include <universal/number/posit/posit.hpp>

template<typename Real>
Real MyKernel(const Real& a, const Real& b) {
    return a * b;  // replace this with your kernel computation
}

constexpr double pi = 3.14159265358979323846;

int main() {
    using Real = sw::universal::posit<32,2>;  

    Real a = sqrt(2);
    Real b = pi;
    std::cout << "Result: " << MyKernel(a, b) << std::endl;
}

Universal delivers software and hardware co-design capabilities to develop low and mixed-precision algorithms for reducing energy consumption in signal processing, Industry 4.0, machine learning, robotics, and high-performance computing applications. The package includes command-line tools for visualizing and interrogating numeric encodings, an interface for setting and querying bits, and educational examples showcasing performance gain and numerical accuracy with the different number systems. In addition, a Docker container is available to experiment without cloning and building from the source code.

Notes

C++ header-only library of plug-in replacements for native arithmetic types.

Files

universal-3.68.zip

Files (24.8 MB)

Name Size Download all
md5:87f5ee9e266e6575d1a4362ee306e92b
11.9 MB Download
md5:8fe73d18c6ae018dd2518259d9433a18
12.9 MB Preview Download