blob: d8392606ce32dea8af3eb001a5130c2a871871f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fixed.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 11:40:49 by charles #+# #+# */
/* Updated: 2020/10/19 12:41:46 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FIXED_HPP
# define FIXED_HPP
# include <iostream>
# include <cmath>
class Fixed
{
public:
Fixed();
Fixed(Fixed const& other);
~Fixed();
Fixed& operator=(Fixed const& other);
Fixed(const int from);
Fixed(const float from);
int getRawBits() const;
void setRawBits(int const raw);
float toFloat() const;
int toInt() const;
Fixed operator+(Fixed const& other) const;
Fixed operator-(Fixed const& other) const;
Fixed operator*(Fixed const& other) const;
Fixed operator/(Fixed const& other) const;
Fixed& operator++();
Fixed& operator--();
Fixed operator++(int);
Fixed operator--(int);
bool operator<(Fixed const& other) const;
bool operator>(Fixed const& other) const;
bool operator<=(Fixed const& other) const;
bool operator>=(Fixed const& other) const;
bool operator==(Fixed const& other) const;
bool operator!=(Fixed const& other) const;
static Fixed& max(Fixed& a, Fixed& b);
static Fixed& min(Fixed& a, Fixed& b);
static const Fixed& max(Fixed const& a, Fixed const& b);
static const Fixed& min(Fixed const& a, Fixed const& b);
static int getFractionalBits();
private:
int m_value;
static int const m_fractionalBits = 8;
};
std::ostream& operator<<(std::ostream& out, Fixed const& f);
#endif
|