From: Lukas Jiriste Date: Thu, 17 Oct 2024 14:27:00 +0000 (+0200) Subject: Change comparison operators to return bool X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=d58e51d3e48f0d34385d63768cd1bec6803c8940;p=42%2FCPP_Module_02 Change comparison operators to return bool --- diff --git a/ex02/Fixed.cpp b/ex02/Fixed.cpp index 502ae74..1d6acbe 100644 --- a/ex02/Fixed.cpp +++ b/ex02/Fixed.cpp @@ -62,32 +62,32 @@ float Fixed::toFloat() const return (static_cast(m_num) / (1 << point_pos)); } -int Fixed::operator==(const Fixed &other) const +bool Fixed::operator==(const Fixed &other) const { return (m_num == other.m_num); } -int Fixed::operator!=(const Fixed &other) const +bool Fixed::operator!=(const Fixed &other) const { return (!(*this == other)); } -int Fixed::operator>(const Fixed &other) const +bool Fixed::operator>(const Fixed &other) const { return (m_num > other.m_num); } -int Fixed::operator<(const Fixed &other) const +bool Fixed::operator<(const Fixed &other) const { return (!(*this >= other)); } -int Fixed::operator>=(const Fixed &other) const +bool Fixed::operator>=(const Fixed &other) const { return (*this == other || *this > other); } -int Fixed::operator<=(const Fixed &other) const +bool Fixed::operator<=(const Fixed &other) const { return (!(*this > other)); } diff --git a/ex02/Fixed.h b/ex02/Fixed.h index 26e03e4..5e3854a 100644 --- a/ex02/Fixed.h +++ b/ex02/Fixed.h @@ -18,12 +18,12 @@ class Fixed Fixed &operator=(const Fixed &other); - int operator==(const Fixed &other) const; - int operator!=(const Fixed &other) const; - int operator>=(const Fixed &other) const; - int operator<=(const Fixed &other) const; - int operator>(const Fixed &other) const; - int operator<(const Fixed &other) const; + bool operator==(const Fixed &other) const; + bool operator!=(const Fixed &other) const; + bool operator>=(const Fixed &other) const; + bool operator<=(const Fixed &other) const; + bool operator>(const Fixed &other) const; + bool operator<(const Fixed &other) const; Fixed operator+(const Fixed &other) const; Fixed operator-(const Fixed &other) const;