E.V.E
v2022.09.01

◆ firstbitunset

eve::firstbitunset = {}
inlineconstexpr

Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit unset in the input.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::unsigned_value T >
T firstbitunset(T x) noexcept;
}
constexpr callable_firstbitunset_ firstbitunset
Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit unset ...
Definition: firstbitunset.hpp:65
Definition: all_of.hpp:22

Parameters

Return value

Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit unset (beginning with the least significant bit) in the input.

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