1 /* 2 * "@(#)bit.c 1.1" 3 * 4 * bit set, clear, test routines 5 * 6 * calling sequences: 7 * logical l, bit, state 8 * call bis (bitnum, word) 9 * call bic (bitnum, word) 10 * call setbit (bitnum, word, state) 11 * l = bit (bitnum, word) 12 * where: 13 * bis(bic) sets(clears) bitnum in word 14 * setbit sets bitnum in word to 1 if state is .true. 15 * bit tests bitnum in word and returns a logical (t/f) value 16 */ 17 18 long bis_(n, w) 19 long *n, *w; 20 { 21 if (*n >= 0 && *n <= 31) 22 *w |= (1L << (*n)); 23 } 24 25 long bic_(n, w) 26 long *n, *w; 27 { 28 if (*n >= 0 && *n <= 31) 29 *w &= ~(1L << (*n)); 30 } 31 32 long bit_(n, w) 33 long *n, *w; 34 { 35 if (*n < 0 || *n > 31) 36 return(0); 37 return((*w & (1L << (*n))) != 0); 38 } 39 40 setbit_(n, w, s) 41 long *n, *w, *s; 42 { 43 if (*s) 44 bis_(n, w); 45 else 46 bic_(n, w); 47 } 48