xref: /freebsd/lib/libc/stdbit/stdc_trailing_zeros.3 (revision d790b16bbf0c3055ef00200d01659dfb3c0e5e5e)
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_TRAILING_ZEROS 3
8.Os
9.Sh NAME
10.Nm stdc_trailing_zeros
11.Nd find the number of trailing zeros in an integer
12.Sh SYNOPSIS
13.Lb libc
14.In stdbit.h
15.Ft unsigned int
16.Fn stdc_trailing_zeros_uc "unsigned char value"
17.Ft unsigned int
18.Fn stdc_trailing_zeros_us "unsigned short value"
19.Ft unsigned int
20.Fn stdc_trailing_zeros_ui "unsigned int value"
21.Ft unsigned int
22.Fn stdc_trailing_zeros_ul "unsigned long value"
23.Ft unsigned int
24.Fn stdc_trailing_zeros_ull "unsigned long long value"
25.Ft unsigned int
26.Fn stdc_trailing_zeros "value"
27.Sh DESCRIPTION
28The
29.Nm stdc_trailing_zeros_ Ns Em type Ns ()
30family of functions returns the number of trailing zeros 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_trailing_zeros "value"
53type-generic macro picks the appropriate
54.Nm stdc_trailing_zeros_ Ns Em type Ns ()
55function based on the type of
56.Fa value .
57.Sh RETURN VALUES
58Returns the number of trailing zeros in
59.Fa value .
60If
61.Fa value
62is all zeros,
63the total number of bits in the type of
64.Fa value
65is returned.
66.Sh SEE ALSO
67.Xr ffs 3 ,
68.Xr stdbit 3 ,
69.Xr stdc_leading_zeros 3 ,
70.Xr stdc_trailing_ones 3 ,
71.Xr stdc_first_trailing_one 3
72.Sh STANDARDS
73The
74.Nm stdc_trailing_zeros_ Ns Em type Ns ()
75family of functions and the
76.Fn stdc_trailing_zeros
77type-generic macro conform to
78.St -isoC-2023 .
79.Sh HISTORY
80The
81.Nm stdc_trailing_zeros_ Ns Em type Ns ()
82family of functions and the
83.Fn stdc_trailing_zeros
84type-generic macro were added in
85.Fx 15.1.
86.Sh AUTHOR
87.An Robert Clausecker Aq Mt fuz@FreeBSD.org
88