.\" .\" Copyright (c) 2025 Robert Clausecker .\" .\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd November 9, 2025 .Dt STDC_HAS_SINGLE_BIT 3 .Os .Sh NAME .Nm stdc_has_single_bit .Nd check for single bit set .Sh SYNOPSIS .Lb libc .In stdbit.h .Ft bool .Fn stdc_has_single_bit_uc "unsigned char value" .Ft bool .Fn stdc_has_single_bit_us "unsigned short value" .Ft bool .Fn stdc_has_single_bit_ui "unsigned int value" .Ft bool .Fn stdc_has_single_bit_ul "unsigned long value" .Ft bool .Fn stdc_has_single_bit_ull "unsigned long long value" .Ft bool .Fn stdc_has_single_bit "value" .Sh DESCRIPTION The .Nm stdc_has_single_bit_ Ns Em type Ns () family of functions checks if there is exactly one bit set in .Fa value , where .Fa value is of type .Va unsigned char , .Va unsigned short , .Va unsigned int , .Va unsigned long , or .Va unsigned long long for .Em type being .Sy uc , .Sy us , .Sy ui , .Sy ul , or .Sy ull respectively. The .Fn stdc_has_single_bit "value" type-generic macro picks the appropriate .Nm stdc_has_single_bit_ Ns Em type Ns () function based on the type of .Fa value . .Pp The functions in this family behave similarly to the .Fn powerof2 "value" macro of .In sys/param.h , but differ when .Fa value is zero: while .Fn powerof2 considers zero to be a power of two, .Fn stdc_has_single_bit does not. .Sh RETURN VALUES Returns .Sy true if exactly one bit is set in .Fa value , otherwise returns .Sy false . I.\^e. the function determines if .Fa value is a power of two. .Sh SEE ALSO .Xr stdbit 3 , .Xr stdc_count_ones 3 .Sh STANDARDS The .Nm stdc_has_single_bit_ Ns Em type Ns () family of functions and the .Fn stdc_has_single_bit type-generic macro conform to .St -isoC-2023 . .Sh HISTORY The .Nm stdc_has_single_bit_ Ns Em type Ns () family of functions and the .Fn stdc_has_single_bit type-generic macro were added in .Fx 15.1. .Sh AUTHOR .An Robert Clausecker Aq Mt fuz@FreeBSD.org