From fe377373e472cc4441d2c7a2e7782ff119764645 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 16 Nov 2023 11:26:41 +0100 Subject: [PATCH] Use identity function in floor if val >= 1/epsilon --- include/boost/math/ccmath/floor.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/boost/math/ccmath/floor.hpp b/include/boost/math/ccmath/floor.hpp index fa071e24b..fb1dea34d 100644 --- a/include/boost/math/ccmath/floor.hpp +++ b/include/boost/math/ccmath/floor.hpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace boost::math::ccmath { @@ -23,6 +24,13 @@ namespace detail { template inline constexpr T floor_pos_impl(T arg) noexcept { + constexpr auto max_comp_val = T(1) / std::numeric_limits::epsilon(); + + if (arg >= max_comp_val) + { + return arg; + } + T result = 1; if(result < arg)