-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecimal.h
43 lines (35 loc) · 1.16 KB
/
decimal.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
#ifndef DECIMAL_H
#define DECIMAL_H
#include "qdecimal/QDecDouble.hh"
class Decimal
{
public:
Decimal();
static Decimal fromCents(long long cents);
static Decimal fromValue(double value);
void operator =(const Decimal& rhs);
void operator +=(const Decimal& rhs);
void operator -=(const Decimal& rhs);
Decimal operator +(const Decimal& rhs) const;
Decimal operator -(const Decimal& rhs) const;
Decimal operator *(const Decimal& rhs) const;
Decimal operator *(const double rhs) const;
Decimal operator *(const int rhs) const;
double operator /(const Decimal& rhs) const;
Decimal operator /(const int rhs) const;
Decimal operator /(const double rhs) const;
bool operator ==(const Decimal& rhs) const;
bool operator !=(const Decimal& rhs) const;
bool operator <(const Decimal& rhs) const;
bool operator <=(const Decimal& rhs) const;
bool operator >(const Decimal& rhs) const;
bool operator >=(const Decimal& rhs) const;
long long cents() const;
double value() const;
private:
Decimal(double value);
Decimal(QDecDouble value);
private:
QDecDouble m_cents = 0.0;
};
#endif // DECIMAL_H