-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx1.c
58 lines (48 loc) · 1.17 KB
/
x1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Test Bits ADT
#include <stdio.h>
#include "defs.h"
#include "reln.h"
#include "tuple.h"
#include "bits.h"
int main(int argc, char **argv)
{
Bits a = newBits(6);
setBit(a,0);
setBit(a,2);
showBits(a); printf("\n");
Bits b = newBits(6);
setBit(b,0);
setBit(b,1);
showBits(b); printf("\n");
Bits c = newBits(6);
setBit(c,1);
setBit(c,2);
showBits(c); printf("\n");
orBits(a,b);
orBits(a,c);
showBits(a); printf("\n");
/*
shiftBits(a,6);
showBits(a); printf("\n");
showBits(a); printf("\n");
Bits b = newBits(60);
printf("t=0: "); showBits(b); printf("\n");
setBit(b, 5);
printf("t=1: "); showBits(b); printf("\n");
setBit(b, 0);
setBit(b, 50);
setBit(b, 59);
printf("t=2: "); showBits(b); printf("\n");
if (bitIsSet(b,5)) printf("Bit 5 is set\n");
if (bitIsSet(b,10)) printf("Bit 10 is set\n");
setAllBits(b);
printf("t=3: "); showBits(b); printf("\n");
unsetBit(b, 40);
printf("t=4: "); showBits(b); printf("\n");
if (bitIsSet(b,20)) printf("Bit 20 is set\n");
if (bitIsSet(b,40)) printf("Bit 40 is set\n");
if (bitIsSet(b,50)) printf("Bit 50 is set\n");
setBit(b, 59);
return 0;
*/
}