E.V.E
v2023.02.15

◆ bit_ceil

eve::bit_ceil = {}
inlineconstexpr

Computes the smallest integral power of two that is not smaller than x.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
T bit_ceil(T x) noexcept;
}
constexpr callable_bit_ceil_ bit_ceil
Computes the smallest integral power of two that is not smaller than x.
Definition: bit_ceil.hpp:64
Definition: abi.hpp:18

Parameters

Return value

The value of the smallest integral power of two that is not smaller than x is returned.

If that value is not representable in T, the behavior is undefined.

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_ceil(pi) = " << eve::bit_ceil(pi) << '\n';
std::uint32_t xf = 48;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bit_ceil(xf) = " << eve::bit_ceil(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_ceil[mask](x, ...) provides a masked version of bit_ceil which is equivalent to if_else(mask, bit_ceil(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_ceil[pi > 4](pi) = " << eve::bit_ceil[pi > 4](pi) << '\n';
    return 0;
    }