42_CPP02/ex02/src/Fixed.hpp
Camille Chauvet 18a2008a96 clean:
2023-08-07 19:06:43 +02:00

49 lines
1.2 KiB
C++

#pragma once
# include <ostream>
class Fixed
{
private:
int _value;
static const int _nb_bits = 8;
public:
Fixed();
Fixed(const Fixed& src);
Fixed(const int &n);
Fixed(const float &f);
~Fixed();
Fixed &operator=(const Fixed& src);
bool operator<(const Fixed& src) const;
bool operator>(const Fixed& src) const;
bool operator>=(const Fixed& src) const;
bool operator<=(const Fixed& src) const;
bool operator==(const Fixed& src) const;
bool operator!=(const Fixed& src) const;
Fixed operator-(const Fixed& src) const;
Fixed operator+(const Fixed& src) const;
Fixed operator*(const Fixed& src) const;
Fixed operator/(const Fixed& src) const;
Fixed &operator++();
Fixed &operator--();
Fixed operator++(int);
Fixed operator--(int);
int getRawBits( void ) const;
void setRawBits( int const raw );
float toFloat(void) const ;
int toInt(void) const ;
static const Fixed& max(const Fixed& f1, const Fixed& f2);
static Fixed& max(Fixed& f1, Fixed& f2);
static const Fixed& min(const Fixed& f1, const Fixed& f2);
static Fixed& min(Fixed& f1, Fixed& f2);
};
std::ostream& operator << (std::ostream &out, const Fixed& fixed);