当前位置: C语言 -- 标准库 -- <stdbit.h> -- stdc_count_zeros_us

stdc_count_zeros_us函数


概要:
#include <stdbit.h>
unsigned int stdc_count_zeros_us(unsigned short value) [[unsequenced]];

描述:

该函数计算参数value中0位的数量;例如:假设unsigned short类型占2个字节,如果参数value值为0X13U,0位的数量是13。

unsequenced类型属性表示:stdc_count_zeros_us函数是无状态、无副作用、幂等、并且是独立的。


参数:
unsigned short value

参数为unsigned short类型对象。


返回值:

该函数返回参数value中0位的数量。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
/*函数stdc_count_zeros_us范例*/

#include <stdbit.h>
#include <stdio.h>

int main(void)
{
    unsigned short value = 0X13U;

    printf("The total number of 0 bits: %u\n", stdc_count_zeros_us(value));

    return 0;
}

可能输出:

The total number of 0 bits: 13

(注:编译时实现未支持<stdbit.h>头文件。)


相关内容:
stdc_count_zeros_uc 计算unsigned char类型对象0位数量的函数。
stdc_count_zeros_ui 计算unsigned int类型对象0位数量的函数。
stdc_count_zeros_ul 计算unsigned long int类型对象0位数量的函数。
stdc_count_zeros_ull 计算unsigned long long int类型对象0位数量的函数。
stdc_count_zeros 计算0位数量的泛型函数。


主要参考资料:

1、ISO/IEC 9899:2024