#pragma once // Exact floating-point comparison helpers. // // The engine caches derived state - filter coefficients, per-voice parameter // snapshots, GUI preview values - and re-derives it only when a stored value // changes. Those checks must stay bit-exact: an epsilon compare would either // keep stale cached state or skip a needed rebuild near the threshold, so the // intent is named here instead of weakened at each call site. // // Every first-party use of == / != on floating point goes through one of these // helpers, and the single -Wfloat-equal suppression lives here rather than // being repeated across the call sites. #include #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif namespace serum { // Exact equality, no epsilon. Used where the exact value carries meaning, such // as "the output level is exactly unity" or "the untouched tail is the zero // default". inline bool exactly (float a, float b) noexcept { return a == b; } inline bool exactly (double a, double b) noexcept { return a == b; } // Exact inequality, for "the cached value changed" tests. inline bool changed (float a, float b) noexcept { return a != b; } inline bool changed (double a, double b) noexcept { return a != b; } // True when a stored double that should hold a whole number really does. inline bool isWholeNumber (double v) noexcept { return std::floor (v) == v; } } // namespace serum #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif