Change comparison operators to return bool
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 17 Oct 2024 14:27:00 +0000 (16:27 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 17 Oct 2024 14:27:00 +0000 (16:27 +0200)
ex02/Fixed.cpp
ex02/Fixed.h

index 502ae743f808eb31ece11504f3b148afa6b01b8f..1d6acbe91ed0cabb76ddd2a2c776dbbbd8419d2e 100644 (file)
@@ -62,32 +62,32 @@ float       Fixed::toFloat() const
        return (static_cast<float>(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));
 }
index 26e03e4ca1c4f3fff00a8e940802ea8b5c206df3..5e3854ad369c025e3beb73664941199f0bf003ec 100644 (file)
@@ -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;