-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy pathtest.cpp
More file actions
102 lines (89 loc) · 1.2 KB
/
test.cpp
File metadata and controls
102 lines (89 loc) · 1.2 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
unsigned int test000(int x) {
if (x < 0) {
x = -x;
}
return x;
}
struct MyStruct {
int myfield;
};
void test001(MyStruct *s) {
if (s->myfield < 0) {
s->myfield = -s->myfield;
}
}
void test002(MyStruct *s, MyStruct *t) {
if (s->myfield < 0) {
s->myfield = -t->myfield;
}
}
unsigned int test003(int x) {
if (0 > x) {
x = -x;
}
return x;
}
unsigned int test004(int x) {
if (x > 0) {
// Do nothing.
} else {
x = -x;
}
return x;
}
unsigned int test005(int x) {
if (0 <= x) {
// Do nothing.
} else {
x = -x;
}
return x;
}
unsigned int test006(int x) {
if (!(0 > x)) {
// Do nothing.
} else {
x = -x;
}
return x;
}
unsigned int test007(int x) {
if (!(x > 0)) {
x = -x;
}
return x;
}
unsigned int test008(int x) {
if (!(0 <= x)) {
x = -x;
}
return x;
}
unsigned int test009(int x) {
if (!!(x < 0)) {
x = -x;
}
return x;
}
unsigned int test010(int x) {
bool b = x < 0;
if (b) {
x = -x;
}
return x;
}
unsigned int test011(int x) {
bool b = !(0 <= x);
if (b) {
x = -x;
}
return x;
}
unsigned int test012(int x) {
bool b = x < 0;
bool c = !b;
if (!c) {
x = -x;
}
return x;
}