Double-double: 31 digits of precision without leaving the FPU

If you ever need more precision than what 15 decimal digits of the double format can offer, there is a neat trick: glue two doubles together and treat them as one number. This gives you ~31 decimal digits for roughly 9x the cost of a plain double in a real kernel (4-12x per isolated operation). With no heap allocation and no dependencies, this puts it almost exactly halfway between a double and an arbitrary-precision library perf-wise. This post explains the error-free transformations that make it work, measures it against MPFR, and shows where the trick runs out of steam.
30 points by iliketrains 66 days ago marekfiser.com 7 comments

Summary

Combining two doubles can yield about 31 decimal digits of precision, offering a cost-effective alternative to arbitrary-precision libraries. This method avoids heap allocation and dependencies, making it a practical solution for high-precision calculations in real kernels.

Comments (7 of ) ⌛

Loading more comments... ⌛
Scroll down to load more comments
No comments available.
Type to search HN and engineering blog articles
Press Escape to close  |  ↑↓ to navigate  |  Enter to open