Format
#include <builtin.h>unsigned int __cntlz4(unsigned int num)
Language Level: None
__cntlz4 calculates the number of leading (ie. most significant)
zero bits in the 4 byte unsigned value num.
Return Value
Returns the number of leading zero bits. If num
is zero, then 32 is returned.
Example
This example calculates the number of leading zero bits
in the 4 byte value 0x00002000.
#include <stdio.h> #include <builtin.h>
unsigned int input = 0x00002000;
int main(void)
{
printf("The number of leading zero bits in %.8x is %u.\n",
input, __cntlz4(input));
/*******************************************************
The output should be:
The number of leading zero bits in 00002000 is 18. *******************************************************/
return 0; }
![]()
__cntlz8 -- Count Leading Zero Bits in 8
Byte Value
__cnttz4 -- Count Trailing Zero Bits in 4
Byte Value
__cnttz8 -- Count Trailing Zero Bits in 8
Byte Value