|
| 1 | +#ifndef FIXED_HPP |
| 2 | +# define FIXED_HPP |
| 3 | + |
| 4 | +#include <iostream> |
| 5 | +#include <cmath> |
| 6 | + |
| 7 | +class Fixed |
| 8 | +{ |
| 9 | +private: |
| 10 | + int value; |
| 11 | + static const int bitCount = 8; |
| 12 | + |
| 13 | +public: |
| 14 | + Fixed(void); |
| 15 | + Fixed(const Fixed& other); |
| 16 | + Fixed(const int number); |
| 17 | + Fixed(const float number); |
| 18 | + ~Fixed(); |
| 19 | + float toFloat(void) const; |
| 20 | + int toInt(void) const; |
| 21 | + int getRawBit(void) const; |
| 22 | + void setRawBit(const int raw); |
| 23 | + Fixed& operator=(const Fixed& other); |
| 24 | + Fixed operator+(const Fixed& other) const; |
| 25 | + Fixed operator-(const Fixed& other) const; |
| 26 | + Fixed operator*(const Fixed& other) const; |
| 27 | + Fixed operator/(const Fixed& other) const; |
| 28 | + Fixed& operator+=(const Fixed& other); |
| 29 | + Fixed& operator-=(const Fixed& other); |
| 30 | + Fixed& operator*=(const Fixed& other); |
| 31 | + Fixed& operator/=(const Fixed& other); |
| 32 | + bool operator>(const Fixed& other) const; |
| 33 | + bool operator<(const Fixed& other) const; |
| 34 | + bool operator>=(const Fixed& other) const; |
| 35 | + bool operator<=(const Fixed& other) const; |
| 36 | + bool operator==(const Fixed& other) const; |
| 37 | + bool operator!=(const Fixed& other) const; |
| 38 | + Fixed& operator++(void); |
| 39 | + Fixed operator++(int); |
| 40 | + Fixed& operator--(void); |
| 41 | + Fixed operator--(int); |
| 42 | + static Fixed& min(Fixed& a, Fixed& b); |
| 43 | + static Fixed& max(Fixed& a, Fixed& b); |
| 44 | + static const Fixed& min(const Fixed& a, const Fixed& b); |
| 45 | + static const Fixed& max(const Fixed& a, const Fixed& b); |
| 46 | +}; |
| 47 | + |
| 48 | +std::ostream& operator<<(std::ostream& os, const Fixed& fixed); |
| 49 | + |
| 50 | +#endif |
0 commit comments