#pragma once

#include <iostream>

class NR {
  public:
	using Int = long long;

  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);

	NR operator-() const;

	NR Inverse() const;

	friend std::ostream& operator<<(std::ostream& os, const NR& opNR);
	friend std::istream& operator>>(std::istream& os, NR& opNR);

  private:
	void Reduce();
};
