/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   Fixed.class.hpp                                    :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: bchanot <bchanot@gmail.fr>                 +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2025/07/16 15:46:39 by bchanot           #+#    #+#             */
/*   Updated: 2025/07/17 18:52:26 by bchanot          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef FIXED_CLASS_H
# define FIXED_CLASS_H

#include <iostream>

class	Fixed {
	public:
		Fixed(void);
		Fixed(Fixed const &src);
		Fixed(int const num);
		Fixed(float const num);
		~Fixed(void);

		int			getRawBits(void) const;
		void		setRawBits(int const raw);
		float		toFloat(void) const;
		int			toInt(void) const;

		Fixed		&operator=(Fixed const &rhs);
		bool		operator!=(Fixed const &rhs) const;
		bool		operator==(Fixed const &rhs) const;
		bool		operator<=(Fixed const &rhs) const;
		bool		operator>=(Fixed const &rhs) const;
		bool		operator<(Fixed const &rhs) const;
		bool		operator>(Fixed const &rhs) const;
		Fixed		operator+(Fixed const &rhs) const;
		Fixed		operator-(Fixed const &rhs) const;
		Fixed		operator*(Fixed const &rhs) const;
		Fixed		operator/(Fixed const &rhs) const;
		Fixed		&operator++();
		Fixed		&operator--();
		Fixed		operator++(int);
		Fixed		operator--(int);

		static const Fixed	&min(Fixed const &left, Fixed const &right);
		static Fixed	&min(Fixed &left, Fixed &right);
		static const Fixed	&max(Fixed const &left, Fixed const &right);
		static Fixed	&max(Fixed &left, Fixed &right);

	private:
		int			_value;
		static int const	_frac = 8;
};

std::ostream	&operator<<(std::ostream &o, Fixed const &i);

#endif
