/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Fixed.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/20 10:06:37 by narnaud #+# #+# */ /* Updated: 2022/06/23 10:33:51 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include #include class Fixed { public: Fixed (void); Fixed (const int init_int); Fixed (const float init_float); Fixed (Fixed const & src); ~Fixed (void); Fixed & operator= (Fixed const & src); Fixed operator+ (Fixed const & src); Fixed operator- (Fixed const & src); Fixed operator* (Fixed const & src); Fixed operator/ (Fixed const & src); Fixed & operator++ (); Fixed & operator-- (); Fixed operator++ (int); Fixed operator-- (int); bool operator< (Fixed const & src); bool operator> (Fixed const & src); bool operator<= (Fixed const & src); bool operator>= (Fixed const & src); bool operator== (Fixed const & src); bool operator!= (Fixed const & src); int getRawBits(void) const; void setRawBits(int const raw); float toFloat(void) const; int toInt(void) const; static Fixed & min(Fixed & a, Fixed & b); static Fixed & max(Fixed & a, Fixed & b); static const Fixed & min(Fixed const & a, Fixed const & b); static const Fixed & max(Fixed const & a, Fixed const & b); private: int _raw_bits; static const int _fract_bits; }; std::ostream & operator << (std::ostream &out, const Fixed &f);