-
Notifications
You must be signed in to change notification settings - Fork 0
/
operators.c
84 lines (68 loc) · 1.09 KB
/
operators.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
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
#include <math.h>
#include <stdlib.h>
double op_1st(double x, double y)
{
return x;
}
double op_2nd(double x, double y)
{
return y;
}
double op_add(double x, double y)
{
return x+y;
}
double op_sub(double x, double y)
{
return x-y;
}
double op_mul(double x, double y)
{
return x*y;
}
double op_div(double x, double y)
{
if(y == 0) y = 0.0000001;
return x/y;
}
double op_and(double x, double y)
{
return (double)((unsigned long)x & (unsigned long)y);
}
double op_or(double x, double y)
{
return (double)((unsigned long)x | (unsigned long)y);
}
double op_xor(double x, double y)
{
return (double)((unsigned long)x ^ (unsigned long)y);
}
double op_not(double x, double y)
{
return (double)(~(unsigned long)x);
}
double op_sin(double x, double y)
{
return sin(x);
}
double op_cos(double x, double y)
{
return cos(x);
}
double op_tan(double x, double y)
{
return tan(x);
}
double op_log(double x, double y)
{
return log(x);
}
double op_exp(double x, double y)
{
return exp(x);
}
double op_inv(double x, double y)
{
if(x == 0) x = 0.0000001;
return 1/x;
}