E.V.E
v2022.09.01

◆ bit_floor

eve::bit_floor = {}
inlineconstexpr

If x is not zero, computes the largest integral power of two that is not greater than x.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
T bit_floor(T x) noexcept;
}
constexpr callable_bit_floor_ bit_floor
If x is not zero, computes the largest integral power of two that is not greater than x.
Definition: bit_floor.hpp:65
Definition: all_of.hpp:22

Parameters

Return value

  • The value of the largest integral power of two that is not greater than x is returned.
  • If x is zero returns zero.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_it pi = {14, 1, 3, 7, 20, 23000, 0, 27};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> bit_floor(pi) = " << eve::bit_floor(pi) << '\n';
std::uint32_t xf = 48;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bit_floor(xf) = " << eve::bit_floor(xf) << '\n';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::bit_floor[mask](x, ...) provides a masked version of bit_floor which is equivalent to if_else(mask, bit_floor(x, ...), x)

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_it pi = {14, 1, 3, 7, 20, 23000, 0, 27};
    std::cout << "---- simd" << '\n'
    << "<- pi = " << pi << '\n'
    << "-> bit_floor[pi > 4](pi) = " << eve::bit_floor[pi > 4](pi) << '\n';
    return 0;
    }