49 lines
1.2 KiB
C++
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);
|