home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource3 / 161_01 / 405.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-08-30  |  322 b   |  19 lines

  1.  
  2. /*
  3.  *    return the bit sum of a byte argument
  4.  *    version 6
  5.  */
  6.  
  7. # include "timer1.h"
  8. # define bitcnt(x) (bitsum[(x) & BYTEMASK])
  9. # define BYTEMASK 0377
  10.  
  11. char c = 15;
  12.  
  13. static char bitsum[256] = {
  14.     '\1', '\0', '\1', '\1', '\2', '\1', '\0', '\1', '\1', '\2', '\1'
  15. };
  16.  
  17. DO_IEXPR("Bit count V6") bitcnt(c)    OD
  18. }
  19.