Skip to content

Commit

Permalink
Fix constexpr cmath floor of 1 returning 0 #1232
Browse files Browse the repository at this point in the history
  • Loading branch information
yousseflakhal committed Jan 12, 2025
1 parent c5d3666 commit adaf1bf
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 adaf1bf

Please sign in to comment.