maint: update copyright
[gnulib.git] / lib / integer_length.h
1 /* integer_length - find most significant bit in an unsigned integer.
2    Copyright (C) 2011-2014 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    This program 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 General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17 /* Written by Bruno Haible <bruno@clisp.org>, 2011.  */
18
19 #ifndef _INTEGER_LENGTH_H
20 #define _INTEGER_LENGTH_H
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
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.  */
30
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);
34
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);
38
39 #if HAVE_UNSIGNED_LONG_LONG_INT
40 /* Returns the integer length of x.
41    The result is >= 0, <= sizeof (unsigned long long) * CHAR_BIT.  */
42 extern int integer_length_ll (unsigned long long x);
43 #endif
44
45 #ifdef __cplusplus
46 }
47 #endif
48
49 #endif /* _INTEGER_LENGTH_H */