Documentation

9.16 Floating-point and platform differences

nlmx primarily uses IEEE-754 binary64 (f64). Basic arithmetic is standardized, but complete runs can differ in last bits across architectures, compiler versions and linked math implementations.

Sources include:

  • exp, log, trigonometric, erfc and gamma-family library functions;
  • eigendecomposition and linear-algebra library paths;
  • fused multiply-add decisions and compiler optimization;
  • summation association and parallel reduction order;
  • adaptive solver branch decisions near an error threshold;
  • optimizer decisions near convergence or parameter bounds.

A one-ulp perturbation can cross a branch, sorting tie or stopping threshold and produce a larger downstream difference. Discrete decisions require margin tests, not only final-value tolerance.

NaN and signed zero

NaN comparisons are unordered; sorting helpers often choose a fallback ordering after filtering or partial comparison. Positive and negative zero compare equal but can affect reciprocals and formatted output. Infinity/NaN should normally be caught before scientific reporting, not normalized silently.

Expected digits

Do not promise a fixed number of digits globally. Well-conditioned analytic predictions may agree near machine precision; ill-conditioned inverses or long stochastic optimizations can agree much less closely. Set tolerances per output class from conditioning and reference evidence.

Platform validation

Run identical frozen fixtures on every supported build. Compare exact categorical outcomes and value arrays with paired absolute/relative thresholds. Record compiler, target features and dependency lockfile. Investigate systematic drift rather than simply widening tolerances.

Common mistakes

  • Assuming IEEE-754 guarantees identical library functions.
  • Applying one tolerance to all outputs.
  • Ignoring branch/stopping decisions near thresholds.

Checklist

  • Identify platform-sensitive operations.
  • Define output-class-specific tolerances.
  • Test discrete decisions with safety margins.

Further reading

See tolerance-based tests, ODE controls and Chapter 42's future validation framework.