date and time created 83/01/21 11:19:18 by dlw
[unix-history] / usr / src / usr.bin / f77 / libF77 / bit.c
CommitLineData
c97b9b30
DW
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
18long bis_(n, w)
19long *n, *w;
20{
21 if (*n >= 0 && *n <= 31)
22 *w |= (1L << (*n));
23}
24
25long bic_(n, w)
26long *n, *w;
27{
28 if (*n >= 0 && *n <= 31)
29 *w &= ~(1L << (*n));
30}
31
32long bit_(n, w)
33long *n, *w;
34{
35 if (*n < 0 || *n > 31)
36 return(0);
37 return((*w & (1L << (*n))) != 0);
38}
39
40setbit_(n, w, s)
41long *n, *w, *s;
42{
43 if (*s)
44 bis_(n, w);
45 else
46 bic_(n, w);
47}