2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Merge pull request #1233 from yousseflakhal/fix-constexpr-floor

Fix constexpr cmath floor of 1 returning 0 #1232
This commit is contained in:
Matt Borland
2025-01-13 08:49:07 -05:00
committed by GitHub
2 changed files with 2 additions and 1 deletions

View File

@@ -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)
{

View File

@@ -32,6 +32,7 @@ constexpr void test()
static_assert(boost::math::ccmath::isinf(boost::math::ccmath::floor(-std::numeric_limits<T>::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));