.. _program_listing_file_include_flamegpu_detail_numeric.h: Program Listing for File numeric.h ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/flamegpu/detail/numeric.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef INCLUDE_FLAMEGPU_DETAIL_NUMERIC_H_ #define INCLUDE_FLAMEGPU_DETAIL_NUMERIC_H_ #include #include #include namespace flamegpu { namespace detail { namespace numeric { template bool approxExactlyDivisible(T x, T y) { // Scale machine epsilon by the magnitude of the larger value T scaledEpsilon = std::max(std::abs(x), std::abs(y)) * std::numeric_limits::epsilon(); // Compute the remainder T v = std::fmod(x, y); // approx equal if the remainder is within scaledEpsilon of 0 or b (fmod(1, 0.05f) returns ~0.05f) return v <= scaledEpsilon || v > y - scaledEpsilon; } } // namespace numeric } // namespace detail } // namespace flamegpu #endif // INCLUDE_FLAMEGPU_DETAIL_NUMERIC_H_