1.\" 2.\" Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org> 3.\" 4.\" SPDX-License-Identifier: BSD-2-Clause 5.\" 6.Dd November 9, 2025 7.Dt STDC_FIRST_LEADING_ZERO 3 8.Os 9.Sh NAME 10.Nm stdc_first_leading_zero 11.Nd find the first leading zero in an integer 12.Sh SYNOPSIS 13.Lb libc 14.In stdbit.h 15.Ft unsigned int 16.Fn stdc_first_leading_zero_uc "unsigned char value" 17.Ft unsigned int 18.Fn stdc_first_leading_zero_us "unsigned short value" 19.Ft unsigned int 20.Fn stdc_first_leading_zero_ui "unsigned int value" 21.Ft unsigned int 22.Fn stdc_first_leading_zero_ul "unsigned long value" 23.Ft unsigned int 24.Fn stdc_first_leading_zero_ull "unsigned long long value" 25.Ft unsigned int 26.Fn stdc_first_leading_zero "value" 27.Sh DESCRIPTION 28The 29.Nm stdc_first_leading_zero_ Ns Em type Ns () 30family of functions returns the index of the most significant clear bit in 31.Fa value , 32where 33.Fa value 34is of type 35.Va unsigned char , 36.Va unsigned short , 37.Va unsigned int , 38.Va unsigned long , 39or 40.Va unsigned long long 41for 42.Em type 43being 44.Sy uc , 45.Sy us , 46.Sy ui , 47.Sy ul , 48or 49.Sy ull 50respectively. 51The 52.Fn stdc_first_leading_zero "value" 53type-generic macro picks the appropriate 54.Nm stdc_first_leading_zero_ Ns Em type Ns () 55function based on the type of 56.Fa value . 57.Sh RETURN VALUES 58Returns the index of the most significant clear bit in 59.Fa value . 60The bits are numbered such that the most significant bit has number\~1, 61and the least significant bit has number 62.Ms w 63where 64.Ms w 65is the number of bits in the type of 66.Fa value . 67If no bits are clear in 68.Fa value 69(i.\^e.\& 70.Fa value 71is the bitwise complement of zero), zero is returned. 72.Sh SEE ALSO 73.Xr stdbit 3 , 74.Xr stdc_leading_ones 3 , 75.Xr stdc_first_leading_ones 3 , 76.Xr stdc_first_trailing_zero 3 77.Sh STANDARDS 78The 79.Nm stdc_first_leading_zero_ Ns Em type Ns () 80family of functions and the 81.Fn stdc_first_leading_zero 82type-generic macro conform to 83.St -isoC-2023 . 84.Sh HISTORY 85The 86.Nm stdc_first_leading_zero_ Ns Em type Ns () 87family of functions and the 88.Fn stdc_first_leading_zero 89type-generic macro were added in 90.Fx 15.1. 91.Sh AUTHOR 92.An Robert Clausecker Aq Mt fuz@FreeBSD.org 93