-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprob.h
More file actions
33 lines (30 loc) · 726 Bytes
/
prob.h
File metadata and controls
33 lines (30 loc) · 726 Bytes
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
#ifndef _PROB_H_
#define _PROB_H_
const double unit = 1e4;
// treated as normal float number:
class prob{
public:
double _d;
prob( ){ _d = 0; }
prob( int _x ){ _d = _x * unit; }
prob( double _x ){ _d = _x * unit; }
inline prob operator+( const prob& tprob ){
return prob( _d + tprob._d );
}
inline prob operator-( const prob& tprob ){
return prob( _d - tprob._d );
}
inline prob operator*( const prob& tprob ){
return prob( _d * tprob._d / unit );
}
inline prob operator/( const prob& tprob ){
return prob( _d / tprob._d * unit );
}
bool operator<( const prob& tprob ){
return _d < tprob._d;
}
inline double value() const{
return _d / unit;
}
};
#endif