(libc.info.gz) Width of Type

Info Catalog (libc.info.gz) Data Type Measurements (libc.info.gz) Range of Type
 
 A.5.1 Computing the Width of an Integer Data Type
 -------------------------------------------------
 
 The most common reason that a program needs to know how many bits are in
 an integer type is for using an array of 'long int' as a bit vector.
 You can access the bit at index N with
 
      vector[N / LONGBITS] & (1 << (N % LONGBITS))
 
 provided you define 'LONGBITS' as the number of bits in a 'long int'.
 
    There is no operator in the C language that can give you the number
 of bits in an integer data type.  But you can compute it from the macro
 'CHAR_BIT', defined in the header file 'limits.h'.
 
 'CHAR_BIT'
      This is the number of bits in a 'char'--eight, on most systems.
      The value has type 'int'.
 
      You can compute the number of bits in any data type TYPE like this:
 
           sizeof (TYPE) * CHAR_BIT
 
Info Catalog (libc.info.gz) Data Type Measurements (libc.info.gz) Range of Type
automatically generated by info2html