feat(ex02): it works
This commit is contained in:
parent
fce90b9a43
commit
6f17e2e888
5 changed files with 251 additions and 0 deletions
51
ex02/Fixed.hpp
Normal file
51
ex02/Fixed.hpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef FIXED_HPP
|
||||
#define FIXED_HPP
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Fixed {
|
||||
public:
|
||||
Fixed();
|
||||
Fixed(const int val);
|
||||
Fixed(const float val);
|
||||
Fixed(const Fixed &other);
|
||||
Fixed &operator=(const Fixed &other);
|
||||
~Fixed();
|
||||
|
||||
int getRawBits(void) const;
|
||||
void setRawBits(int const raw);
|
||||
|
||||
float toFloat(void) const;
|
||||
int toInt(void) const;
|
||||
|
||||
std::string toBin(void) const;
|
||||
|
||||
bool operator>(const Fixed &other) const;
|
||||
bool operator<(const Fixed &other) const;
|
||||
bool operator>=(const Fixed &other) const;
|
||||
bool operator<=(const Fixed &other) const;
|
||||
bool operator==(const Fixed &other) const;
|
||||
bool operator!=(const Fixed &other) const;
|
||||
|
||||
const Fixed operator+(const Fixed &other) const;
|
||||
const Fixed operator-(const Fixed &other) const;
|
||||
const Fixed operator*(const Fixed &other) const;
|
||||
const Fixed operator/(const Fixed &other) const;
|
||||
Fixed operator++();
|
||||
Fixed operator--();
|
||||
Fixed operator++(int);
|
||||
Fixed operator--(int);
|
||||
|
||||
static Fixed &min(Fixed &left, Fixed &right);
|
||||
static const Fixed &min(const Fixed &left, const Fixed &right);
|
||||
static Fixed &max(Fixed &left, Fixed &right);
|
||||
static const Fixed &max(const Fixed &left, const Fixed &right);
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &stream, const Fixed &fixed);
|
||||
|
||||
private:
|
||||
int value;
|
||||
static const int fracbits;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue