summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/bitops.c
blob: 1d0c0bc537ba0a22cd8db6ea7ff475502dbb84cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
**  Bit set, clear, and test operations
**
**  public domain snippet by Bob Stout
*/

typedef enum {ERROR = -1, FALSE, TRUE} LOGICAL;

#define BOOL(x) (!(!(x)))

#define BitSet(arg,posn) ((arg) | (1L << (posn)))
#define BitClr(arg,posn) ((arg) & ~(1L << (posn)))
#define BitTst(arg,posn) BOOL((arg) & (1L << (posn)))