42_CPP02/ex02/src/Fixed.hpp

49 lines
1.2 KiB
C++
Raw Normal View History

2023-08-07 13:06:32 -04:00
#pragma once
2023-08-03 08:01:36 -04:00
# 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);
2023-08-03 11:47:31 -04:00
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;
2023-08-03 08:25:38 -04:00
2023-08-03 11:47:31 -04:00
Fixed operator-(const Fixed& src) const;
Fixed operator+(const Fixed& src) const;
Fixed operator*(const Fixed& src) const;
Fixed operator/(const Fixed& src) const;
2023-08-03 08:25:38 -04:00
Fixed &operator++();
Fixed &operator--();
Fixed operator++(int);
Fixed operator--(int);
2023-08-03 08:01:36 -04:00
int getRawBits( void ) const;
void setRawBits( int const raw );
float toFloat(void) const ;
int toInt(void) const ;
2023-08-03 08:25:38 -04:00
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);
2023-08-03 08:01:36 -04:00
};
std::ostream& operator << (std::ostream &out, const Fixed& fixed);