exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / integer_length.h
blob12500ac2ca76dc2550ed797dc3a58a5f2798e2ff
1 /* integer_length - find most significant bit in an unsigned integer.
2 Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2011. */
19 #ifndef _INTEGER_LENGTH_H
20 #define _INTEGER_LENGTH_H
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
26 /* These functions return the minimum number of bits required to represent
27 the given unsigned integer.
28 For non-zero values, this is the position of the most significant bit
29 that is set, plus one. For zero, it is 0. */
31 /* Returns the integer length of x.
32 The result is >= 0, <= sizeof (unsigned int) * CHAR_BIT. */
33 extern int integer_length (unsigned int x);
35 /* Returns the integer length of x.
36 The result is >= 0, <= sizeof (unsigned long) * CHAR_BIT. */
37 extern int integer_length_l (unsigned long x);
39 /* Returns the integer length of x.
40 The result is >= 0, <= sizeof (unsigned long long) * CHAR_BIT. */
41 extern int integer_length_ll (unsigned long long x);
43 #ifdef __cplusplus
45 #endif
47 #endif /* _INTEGER_LENGTH_H */