-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathulimitedrational.h
34 lines (23 loc) · 893 Bytes
/
ulimitedrational.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
#pragma once
#include "ulimitedint.h"
#include <string>
using namespace std;
class UnlimitedRational {
private:
UnlimitedInt* p;
UnlimitedInt* q;
public:
UnlimitedRational();
UnlimitedRational(UnlimitedInt* num, UnlimitedInt* den);
~UnlimitedRational();
UnlimitedInt* get_p();
UnlimitedInt* get_q();
string get_p_str(); // Return the numerator as a string
string get_q_str(); // Return the denominator as a string
string get_frac_str(); // Return the rational as "p/q"
// Rational arithmetic operations
static UnlimitedRational* add(UnlimitedRational* i1, UnlimitedRational* i2);
static UnlimitedRational* sub(UnlimitedRational* i1, UnlimitedRational* i2);
static UnlimitedRational* mul(UnlimitedRational* i1, UnlimitedRational* i2);
static UnlimitedRational* div(UnlimitedRational* i1, UnlimitedRational* i2);
};