🐛 Fix bit_ceil() to return 1 for input 0 as per specification

This commit is contained in:
Abhay Kumar
2025-06-06 14:23:26 +05:30
parent 21761b3f62
commit f32cb2f696
2 changed files with 3 additions and 3 deletions

View File

@ -703,7 +703,7 @@ BOOST_CXX14_CONSTEXPR inline boost::uint32_t bit_ceil_impl( boost::uint32_t x )
{ {
if( x == 0 ) if( x == 0 )
{ {
return 0; return 1;
} }
--x; --x;
@ -723,7 +723,7 @@ BOOST_CXX14_CONSTEXPR inline boost::uint64_t bit_ceil_impl( boost::uint64_t x )
{ {
if( x == 0 ) if( x == 0 )
{ {
return 0; return 1;
} }
--x; --x;

View File

@ -21,7 +21,7 @@ template<class T> void test_bit_ceil( T x )
if( x == 0 ) if( x == 0 )
{ {
BOOST_TEST_EQ( y, 0 ); BOOST_TEST_EQ( y, 1 );
} }
else else
{ {