-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator_test.h
60 lines (54 loc) · 1.31 KB
/
calculator_test.h
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
#define PI (3.14159265358979323)
typedef enum { add=0, sub=1, mult=2, divi=3, } opcode;
typedef double (*ftable[])(const double&, const double&);
class calculator
{
protected:
double reg[16];
static double (*ftab[4])(const double&, const double&);
static double fadd(const double &, const double &);
static double fsub(const double &, const double &);
static double fmult(const double &, const double &);
static double fdiv(const double &, const double &);
public:
static double exec(opcode, const double &arg1, const double &arag2);
static int main();
};
class real
{
protected:
union
{
int i;
DWORD dw;
struct
{
unsigned int f:23;
unsigned int e:8;
unsigned int s:1;
};
};
short sign();
short exp();
int frac();
static real add(real,real);
static real sub(real,real);
public:
bool operator ==(real arg);
bool operator !=(real arg);
bool operator >=(real arg);
bool operator <=(real arg);
bool operator >(real arg);
bool operator <(real arg);
real operator +(real arg);
real operator +=(real arg);
real operator -(real arg);
real operator -=(real arg);
real operator *(real arg);
real operator /(real arg);
real operator =(real arg);
real () { dw = 0; }
real (float);
operator float ();
// operator silly_rabbit ();
};