root/maint/gnulib/lib/integer_length.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /* integer_length - find most significant bit in an unsigned integer.
   2    Copyright (C) 2011-2021 Free Software Foundation, Inc.
   3 
   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.
   8 
   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.
  13 
  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/>.  */
  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 /* 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);
  42 
  43 #ifdef __cplusplus
  44 }
  45 #endif
  46 
  47 #endif /* _INTEGER_LENGTH_H */

/* [previous][next][first][last][top][bottom][index][help] */