/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Fixed.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lfirmin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/02 12:25:41 by lfirmin #+# #+# */ /* Updated: 2025/07/16 14:41:55 by lfirmin ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FIXED_HPP # define FIXED_HPP #include #include class Fixed { private: int _fixed_p_n; static const int _number_fractional_bits; public: //const/dest Fixed(); Fixed(const int input); Fixed(const float input); Fixed(const Fixed ©); ~Fixed(); // Overloaded Operators Fixed &operator=(const Fixed &src); // Comparison Operators bool operator>(Fixed fixed)const; bool operator<(Fixed fixed)const; bool operator>=(Fixed fixed)const; bool operator<=(Fixed fixed)const; bool operator==(Fixed fixed)const; bool operator!=(Fixed fixed)const; // Arithmetic Operators float operator+(Fixed fixed)const; float operator-(Fixed fixed)const; float operator*(Fixed fixed)const; float operator/(Fixed fixed)const; // pre-increment Operators Fixed operator++(); Fixed operator--(); // post-increment Operators Fixed operator++(int); Fixed operator--(int); //pub method float toFloat(void)const; int toInt(void)const; //get/set int getRawBits(void) const; void setRawBits(int const raw); static Fixed &min(Fixed &first, Fixed &second); static const Fixed &min(Fixed const &first, Fixed const &second); static Fixed &max(Fixed &first, Fixed &second); static const Fixed &max(Fixed const &first, const Fixed &second); }; std::ostream &operator<<(std::ostream &o, Fixed const &fixed); #endif