Skip to content

Commit

Permalink
Merge pull request #1233 from yousseflakhal/fix-constexpr-floor
Browse files Browse the repository at this point in the history
Fix constexpr cmath floor of 1 returning 0 #1232
  • Loading branch information
mborland authored Jan 13, 2025
2 parents c5d3666 + adaf1bf commit 933faf4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/floor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions test/ccmath_floor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 933faf4

Please sign in to comment.