-
Notifications
You must be signed in to change notification settings - Fork 0
/
fraction.h
31 lines (27 loc) · 823 Bytes
/
fraction.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
#include <string>
#ifndef FRAC_H
#define FRAC_H
class fraction {
private:
long long n;
long long d;
void reduce();
public:
static const fraction ZERO;
static const fraction ONE;
fraction(long long n, long long d);
fraction inv() const;
fraction operator+(const fraction &f2) const;
fraction operator-(const fraction &f2) const;
fraction operator*(const fraction &f2) const;
fraction operator/(const fraction &f2) const;
bool operator<(const fraction &f2) const;
bool operator==(const fraction &f2) const;
bool operator!=(const fraction &f2) const;
bool operator>(const fraction &f2) const;
bool operator<=(const fraction &f2) const;
bool operator>=(const fraction &f2) const;
double to_double() const;
std::string to_string() const;
};
#endif