add more doc

This commit is contained in:
2024-02-29 22:24:42 +01:00
parent 9028b553c3
commit 8c1c3d4f9e
9 changed files with 182 additions and 76 deletions

45
include/NR.h Normal file
View File

@@ -0,0 +1,45 @@
#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);