home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / snippets / bitops.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-17  |  384 b   |  15 lines

  1. /*
  2. **  Bit set, clear, and test operations
  3. **
  4. **  public domain snippet by Bob Stout
  5. */
  6.  
  7. typedef enum {ERROR = -1, FALSE, TRUE} LOGICAL;
  8.  
  9. #define BOOL(x) (!(!(x)))
  10.  
  11. #define BitSet(arg,posn) ((arg) | (1L << (posn)))
  12. #define BitClr(arg,posn) ((arg) & ~(1L << (posn)))
  13. #define BitTst(arg,posn) BOOL((arg) & (1L << (posn)))
  14. #define BitFlp(arg,posn) ((arg) ^ (1L << (posn)))
  15.