52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#ifndef FIXED_HPP
|
|
# define FIXED_HPP
|
|
|
|
# include <iostream>
|
|
# include <string>
|
|
# include <cmath>
|
|
|
|
class Fixed {
|
|
public:
|
|
Fixed(void);
|
|
Fixed(int const raw);
|
|
Fixed(float const raw);
|
|
Fixed(const Fixed &fixed);
|
|
~Fixed();
|
|
Fixed& operator=(const Fixed &fixed);
|
|
|
|
static const Fixed& min(Fixed& a, Fixed& b);
|
|
static const Fixed& max(Fixed& a, Fixed& b);
|
|
static const Fixed& min(const Fixed& a, const Fixed& b);
|
|
static const Fixed& max(const Fixed& a, const Fixed& b);
|
|
|
|
bool operator>(const Fixed& fixed) const;
|
|
bool operator<(const Fixed& fixed) const;
|
|
bool operator>=(const Fixed& fixed) const;
|
|
bool operator<=(const Fixed& fixed) const;
|
|
bool operator==(const Fixed& fixed) const;
|
|
bool operator!=(const Fixed& fixed) const;
|
|
|
|
Fixed operator+(const Fixed& fixed) const;
|
|
Fixed operator-(const Fixed& fixed) const;
|
|
Fixed operator*(const Fixed& fixed) const;
|
|
Fixed operator/(const Fixed& fixed) const;
|
|
|
|
Fixed& operator++();
|
|
Fixed operator++(int);
|
|
Fixed& operator--();
|
|
Fixed operator--(int);
|
|
|
|
int toInt(void) const;
|
|
float toFloat(void) const;
|
|
|
|
int getRawBits(void) const;
|
|
void setRawBits(int const raw);
|
|
private:
|
|
int rawBits;
|
|
const static int bits = 8;
|
|
};
|
|
|
|
std::ostream& operator<<(std::ostream& os, const Fixed& fixed);
|
|
|
|
#endif
|