This repository has been archived on 2025-02-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Pivot/include/NR.h
2024-02-29 22:24:42 +01:00

46 lines
1.0 KiB
C++

#pragma once
#include <iostream>
class NR {
private:
int m_Numerator;
int m_Denominator; // has to be > 0, sign is carried by the numerator
public:
NR();
NR(int entier);
NR(int numerator, int denominator); // check if denominator != 0
int GetNumerator() const;
int GetDenominator() const;
bool operator==(const NR& opNR) const;
bool operator<(const NR& opNR) const;
bool operator>(const NR& opNR) const;
bool operator!=(const NR& opNR) const;
bool operator<=(const NR& opNR) const;
bool operator>=(const NR& opNR) const;
NR operator+(const NR& opNR) const;
NR operator-(const NR& opNR) const;
NR operator*(const NR& opNR) const;
NR operator/(const NR& opNR) const;
NR& operator+=(const NR& opNR);
NR& operator-=(const NR& opNR);
NR& operator*=(const NR& opNR);
NR& operator/=(const NR& opNR);
void Invert();
friend std::ostream& operator<<(std::ostream& os, const NR& opNR);
friend std::istream& operator>>(std::istream& os, NR& opNR);
private:
void Reduce();
};
int PGCD(int x, int y);