root / logic / trunk / src / logics / operators.c @ 61
History | View | Annotate | Download (1.19 KB)
1 |
#include "operators.h" |
---|---|
2 |
#include <stdio.h> |
3 |
|
4 |
int evalOperators(int opr, int a, int b) |
5 |
{ |
6 |
switch(opr)
|
7 |
{ |
8 |
case AND:
|
9 |
//printf("\t--- Evaluating a %d && b %d = %d\n",a,b,a&&b);
|
10 |
return a&&b;
|
11 |
case NOT_AND:
|
12 |
//printf("\t--- Evaluating !(a %d && b %d) = %d\n",a,b, !(a&&b));
|
13 |
return !(a&&b);
|
14 |
case OR:
|
15 |
//printf("\t--- Evaluating a %d || b %d = %d\n",a,b, a||b);
|
16 |
return a||b;
|
17 |
case XOR:
|
18 |
//printf("\t--- Evaluating (!a %d && b %d )||(a %d && !b %d)= %d\n",a,b,a,b,(!a&&b)||(a&&!b));
|
19 |
return (!a&&b)||(a&&!b);
|
20 |
case GREATER:
|
21 |
//printf("\t--- Evaluating a %d > b %d = %d\n",a,b, a>b);
|
22 |
return a>b;
|
23 |
case GREATER_OR_EQUAL:
|
24 |
//printf("\t--- Evaluating a %d >= b %d = %d\n",a,b, a>=b);
|
25 |
return a>=b;
|
26 |
case LESS:
|
27 |
//printf("\t--- Evaluating a %d < b %d = %d\n",a,b, a<b);
|
28 |
return a<b;
|
29 |
case LESS_OR_EQUAL:
|
30 |
//printf("\t--- Evaluating a %d <= b %d = %d\n",a,b, a<=b);
|
31 |
return a<=b;
|
32 |
default:
|
33 |
printf("Evaluation gone wrong!\n");
|
34 |
return NULL; |
35 |
} |
36 |
return NULL; |
37 |
} |