|
|
|
@ -34,10 +34,10 @@ class fraction {
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Constructors
|
|
|
|
|
fraction() {
|
|
|
|
|
}
|
|
|
|
|
fraction() {}
|
|
|
|
|
fraction(const fraction &q) {
|
|
|
|
|
signed long long hcf = gcd(q.n, q.d);
|
|
|
|
|
n = q.n / hcf;
|
|
|
|
@ -70,15 +70,9 @@ class fraction {
|
|
|
|
|
d = q.d;
|
|
|
|
|
}
|
|
|
|
|
// Member functions
|
|
|
|
|
int get_sign() const {
|
|
|
|
|
return (!(n >= 0) != !(d >=0)) ? -1 : 1;
|
|
|
|
|
}
|
|
|
|
|
signed long long get_n() const {
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
signed long long get_d() const {
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
int get_sign() const { return (!(n >= 0) != !(d >= 0)) ? -1 : 1; }
|
|
|
|
|
signed long long get_n() const { return n; }
|
|
|
|
|
signed long long get_d() const { return d; }
|
|
|
|
|
double to_double() const {
|
|
|
|
|
double dec = (double)n / (double)d;
|
|
|
|
|
return dec;
|
|
|
|
|