bitset_count_ones()
Returns the number of set bits in the binary representation of a number.
Syntax
bitset_count_ones(
value)
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
value | int |
✔️ | The value for which to calculate the number of set bits. |
Returns
Returns the number of set bits in the binary representation of a number.
Example
// 42 = 32+8+2 : b'00101010' == 3 bits set
print ones = bitset_count_ones(42)
Output
ones |
---|
3 |
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for