arXiv:2609.07492cs.SESep 2026

Manuscript Offprint

arXiv:2609.07492

FPScan: An Automated Constraint-Based Analyzer for Floating-Point Anomaly Detection

Julien Bortolussi, Dorra Ben Khalifa, Pierre-Loïc Garoche

Julien Bortolussi, Dorra Ben Khalifa, and Pierre-Loïc Garoche

Fédération ENAC ISAE-SUPAERO ONERA, Université de Toulouse, Toulouse, France

{julien.bortolussi,dorra.ben-khalifa,pierre-loic.garoche}@enac.fr

Abstract—Writing error-free floating-point programs is a challenging task, especially for programmers who lack a strong background in numerical analysis and rounding-error propagation. State-of-the-art techniques typically aim to bound such errors using static or dynamic analysis. However, only a few tools explicitly address critical floating-point pitfalls such as absorption and catastrophic cancellation. These anomalies represent situations in which rounding errors are significantly amplified, causing the semantics of the finite-precision computation to deviate substantially from the real-number semantics. In this article, we present FPScan, a novel tool to formally define and detect both catastrophic cancellation and absorption in floating-point programs. Our approach starts with a custom static analyzer based on abstract interpretation to infer the order of magnitude of all program variables. This magnitude information is then used to build a set of first-order constraints that model error propagation and numerical precision within the program. Finally, we employ an off-the-shelf SMT solver to determine whether the program exhibits any of these critical numerical pitfalls. Experiments were conducted on FPBench, a well-known benchmark suite of floating-point programs, to evaluate the effectiveness of our tool. We also present a comparison with state-of-the-art tools regarding soundness and analysis time.

Index Terms—Floating-point arithmetic, Static analysis, Catastrophic cancellation, Absorption, Constraint generation, SMT solver.

I. INTRODUCTION

Floating-point arithmetic is the standard approach for approximating real-number computations in modern computing systems [1]. By representing numbers in a scientific-notation format with a finite significand and a bounded exponent, it supports a large dynamic range while keeping relative errors small. However, this representation implies that floating-point numbers are not uniformly distributed over the real line. As a consequence, certain operations may introduce significant numerical errors. Two well-known examples are absorption and catastrophic cancellation. Absorption occurs when adding numbers with vastly different magnitudes, causing the smaller value to be lost due to rounding. Catastrophic cancellation arises when subtracting nearly equal numbers, amplifying previously accumulated rounding errors.

In practice, many floating-point expressions are implemented by developers without specialized training in numerical analysis, which makes diagnosing such numerical issues difficult. As a result, developers often rely on iterative trial-and-error modifications guided by test inputs, an approach that is both inefficient and unreliable [2].

Floating-point experts typically describe these phenomena as numerical pitfalls that explain the origins of many floating-point errors [2]–[4]. However, relatively little work has investigated how these pitfalls could be systematically exploited, either to assist developers in identifying problematic computations or to automatically generate more accurate expressions.

In this article, we introduce FPScan 1^{1}, a tool for soundly and automatically detecting floating-point pitfalls. FPScan is based on the principle that pitfalls are closely related to the relative orders of magnitude of operands and the magnitude of the associated rounding errors. To exploit this property, FPScan first performs a static range analysis to infer interval bounds for program variables and intermediate expressions. These bounds are then used to approximate the orders of magnitude of values involved in computations. FPScan abstracts these orders of magnitude using integer variables and generates constraints that characterize conditions under which numerical pitfalls, such as absorption and catastrophic cancellation, may occur. The resulting constraints are checked using the Z3 SMT solver to determine whether such situations are detected within the inferred ranges. We evaluate FPScan using the FPBench benchmark suite [5] and compare it with FPChecker [6], [7], a state-of-the-art dynamic tool for detecting floating-point cancellations, and with a bitblasting-based approach. Our results show that FPScan achieves high precision while remaining computationally efficient.

The three main contributions of this article are:

  1. An efficient constraint-based method for detecting absorption and catastrophic cancellation in floating-point computations (including denormalized numbers) based on order-of-magnitude reasoning (sections II and III).

  2. FPScan, a tool based on static analysis that combines interval range analysis with SMT solving to automatically detect floating-point pitfalls (Section III).

  3. An experimental evaluation on the FPBench benchmark suite, including comparisons with FPChecker and a bitblasting-based approach (Section IV). It demonstrates the efficiency and accuracy of FPScan.

References (25)