This commit is contained in:
Camille Chauvet 2023-08-03 17:47:31 +02:00
parent 1d752c591b
commit 7de4817171
2 changed files with 23 additions and 23 deletions

View File

@ -10,7 +10,7 @@ Fixed::~Fixed()
Fixed::Fixed() Fixed::Fixed()
{ {
ths->_value = 0; this->_value = 0;
std::cout << "Default constructor called" << std::endl; std::cout << "Default constructor called" << std::endl;
} }
@ -93,52 +93,52 @@ Fixed Fixed::operator--(int)
return (tmp); return (tmp);
} }
bool Fixed::operator==(const Fixed& src) bool Fixed::operator==(const Fixed& src) const
{ {
return (this->_value == src._value); return (this->_value == src._value);
} }
bool Fixed::operator!=(const Fixed& src) bool Fixed::operator!=(const Fixed& src) const
{ {
return (this->_value != src._value); return (this->_value != src._value);
} }
bool Fixed::operator>=(const Fixed& src) bool Fixed::operator>=(const Fixed& src) const
{ {
return (this->_value >= src._value); return (this->_value >= src._value);
} }
bool Fixed::operator<=(const Fixed& src) bool Fixed::operator<=(const Fixed& src) const
{ {
return (this->_value <= src._value); return (this->_value <= src._value);
} }
bool Fixed::operator>(const Fixed& src) bool Fixed::operator>(const Fixed& src) const
{ {
return (this->_value > src._value); return (this->_value > src._value);
} }
bool Fixed::operator<(const Fixed& src) bool Fixed::operator<(const Fixed& src) const
{ {
return (this->_value < src._value); return (this->_value < src._value);
} }
Fixed Fixed::operator*(const Fixed &src) Fixed Fixed::operator*(const Fixed &src) const
{ {
return Fixed(this->toFloat() * src.toFloat()); return Fixed(this->toFloat() * src.toFloat());
} }
Fixed Fixed::operator/(const Fixed &src) Fixed Fixed::operator/(const Fixed &src) const
{ {
return Fixed(this->toFloat() / src.toFloat()); return Fixed(this->toFloat() / src.toFloat());
} }
Fixed Fixed::operator+(const Fixed &src) Fixed Fixed::operator+(const Fixed &src) const
{ {
return Fixed(this->toFloat() + src.toFloat()); return Fixed(this->toFloat() + src.toFloat());
} }
Fixed Fixed::operator-(const Fixed &src) Fixed Fixed::operator-(const Fixed &src) const
{ {
return Fixed(this->toFloat() - src.toFloat()); return Fixed(this->toFloat() - src.toFloat());
} }
@ -159,14 +159,14 @@ Fixed& Fixed::max(Fixed& f1, Fixed &f2)
const Fixed& Fixed::min(const Fixed& f1, const Fixed &f2) const Fixed& Fixed::min(const Fixed& f1, const Fixed &f2)
{ {
if (f1._value > f2._value) if (f1._value < f2._value)
return (f1); return (f1);
return (f2); return (f2);
} }
Fixed& Fixed::min(Fixed& f1, Fixed &f2) Fixed& Fixed::min(Fixed& f1, Fixed &f2)
{ {
if (f1._value > f2._value) if (f1._value < f2._value)
return (f1); return (f1);
return (f2); return (f2);
} }

View File

@ -18,17 +18,17 @@ class Fixed
Fixed &operator=(const Fixed& src); Fixed &operator=(const Fixed& src);
bool operator<(const Fixed& src); bool operator<(const Fixed& src) const;
bool operator>(const Fixed& src); bool operator>(const Fixed& src) const;
bool operator>=(const Fixed& src); bool operator>=(const Fixed& src) const;
bool operator<=(const Fixed& src); bool operator<=(const Fixed& src) const;
bool operator==(const Fixed& src); bool operator==(const Fixed& src) const;
bool operator!=(const Fixed& src); bool operator!=(const Fixed& src) const;
Fixed operator-(const Fixed& src); Fixed operator-(const Fixed& src) const;
Fixed operator+(const Fixed& src); Fixed operator+(const Fixed& src) const;
Fixed operator*(const Fixed& src); Fixed operator*(const Fixed& src) const;
Fixed operator/(const Fixed& src); Fixed operator/(const Fixed& src) const;
Fixed &operator++(); Fixed &operator++();