Floating-Point Error Handling in C++: What Actually Works

Floating-Point Error Handling in C++: What Actually Works

Floating-point errors are unavoidable, but how you detect and handle them can make the difference between clean, high-performance C++ code and a debugging nightmare. In this article, we explore the practical techniques for handling NaNs, infinities, and other FP errors — from manual checks to sticky bits and hardware traps — and reveal which approaches actually work without sabotaging performance.

Decreasing the Number of Memory Accesses: The Compiler’s Secret Life 2/2

Decreasing the Number of Memory Accesses: The Compiler’s Secret Life 2/2

We investigate memory loads and stores that the compiler inserts for us without our knowledge: “the compiler’s secret life”. We show that these loads and stores, although necessary for the compiler are not necessary for the correct functioning of our program. And finally, we explain how you can improve the performance of your program by removing them.