diff --git a/include/boost/math/ccmath/floor.hpp b/include/boost/math/ccmath/floor.hpp index fb1dea34db..5afed7d0ca 100644 --- a/include/boost/math/ccmath/floor.hpp +++ b/include/boost/math/ccmath/floor.hpp @@ -33,7 +33,7 @@ inline constexpr T floor_pos_impl(T arg) noexcept T result = 1; - if(result < arg) + if(result <= arg) { while(result < arg) { diff --git a/test/ccmath_floor_test.cpp b/test/ccmath_floor_test.cpp index ddd0a53e9d..bcc9cc1790 100644 --- a/test/ccmath_floor_test.cpp +++ b/test/ccmath_floor_test.cpp @@ -32,6 +32,7 @@ constexpr void test() static_assert(boost::math::ccmath::isinf(boost::math::ccmath::floor(-std::numeric_limits::infinity())), "If x is +- inf, it is returned, unmodified"); + static_assert(boost::math::ccmath::floor(T(1.0)) == T(1.0)); static_assert(boost::math::ccmath::floor(T(2)) == T(2)); static_assert(boost::math::ccmath::floor(T(2.4)) == T(2)); static_assert(boost::math::ccmath::floor(T(2.9)) == T(2));