E.V.E
v2022.09.01

◆ bit_width

eve::bit_width = {}
inlineconstexpr

Computes elementwise the number of bits needed to store the parameter.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::unsigned_value T >
T bit_width(T x) noexcept;
}
constexpr callable_bit_width_ bit_width
Computes elementwise the number of bits needed to store the parameter.
Definition: bit_width.hpp:51
Definition: all_of.hpp:22

Parameters

Return value

The value of number of bits needed to store the value x, i.e. \(1+\lfloor\log2(x)\rfloor\) is returned.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_it pi = {14, 1, 3, 0};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> bit_width(pi) = " << eve::bit_width(pi) << '\n';
std::uint32_t xf = 48;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bit_width(xf) = " << eve::bit_width(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