“CNL: A Compositional Numeric Library”
summary
CNL presents a composable numerics library that gives zero-cost abstractions over integers: fixed_point adds a binary radix to an integer, multiplication doubles fractional bits and squares double the exponent, division requires a special divide helper (half of integer divisions yield zero); elastic_integer auto-widens (e.g., 32→64 bits, 31→62 for products) to avoid overflow; safe_integer traps run-time overflow. Uses heavy static_asserts (≈1000 checks), class template deduction and user literals (_c, _elastic), interoperates with Boost.Multiprecision (googol inverse) and Boost.SIMD (Mandelbrot), and mostly matches raw int performance except slower, shifted division.
AI-written summary · about
chapters (14)
- 0:00Introduction and motivation
- 1:03Problems with numeric types
- 4:37CNL library goals and design
- 8:27Fixed point basics
- 13:31Limitations of fixed point
- 18:12Multiplication and division issues
- 22:32Division challenges
- 29:08Elastic integer type
- 38:56Safe integer for runtime checks
- 44:02User-defined literals
- 49:08Elastic fixed point
- 52:28Interoperability with other libraries
- 54:57Roadmap and future work
- 57:46Q&A
related talks
35mSecure Numerical Computing is Hard: Lessons from 10 Years of Open Data Science & the Long Road Ahead
50mElevating Precision in C++ - A Journey Below the Surface of Floating-Point
17mMiniFloat-NN: A RISC-V ISA Extension for Low-Precision NN Training
48mDemystifying Floating Point
15mQuantization with Guaranteed Floating-Point Neural Network Classifications
01h 04mSymbolic Calculus for High-performance Computing From Scratch Using C++23
41mGeneric Math in .NET 7
01h 06mNumerical Integrators From Scratch in C++
