countbits¶
Description¶
Population count. Counts the number of set bits in the binary representation of a value.
Signature¶
uint countbits<T>(T value) where T : __BuiltinIntegerType; vector<uint, N> countbits<T, int N>(vector<T, N> value) where T : __BuiltinIntegerType;
Generic Parameters¶
T: __BuiltinIntegerType¶
N : int¶
Parameters¶
value : T¶
The value to count bits in.
value : vector<T, N>¶
The value to count bits in.
Return value¶
The number of bits in the binary representation of value that are set to one.
Remarks¶
For SPIR-V, this function maps to OpBitCount.
Availability and Requirements¶
Defined for the following targets:
hlsl¶
Available in all stages.
glsl¶
Available in all stages.
cpp¶
Available in all stages.
cuda¶
Available in all stages.
metal¶
Available in all stages.
wgsl¶
Available in all stages.
spirv¶
Available in all stages.
llvm¶
Available in all stages.