-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFixed.hpp
More file actions
63 lines (51 loc) · 2.1 KB
/
Fixed.hpp
File metadata and controls
63 lines (51 loc) · 2.1 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fixed.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zelhajou <zelhajou@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/13 17:24:51 by zelhajou #+# #+# */
/* Updated: 2024/06/14 14:09:36 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FIXED_HPP
# define FIXED_HPP
#include <iostream>
class Fixed
{
private:
int _fixedPointValue;
static const int _fractionalBits = 8;
public:
Fixed();
Fixed(const int intVal);
Fixed(const float floatVal);
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;
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;
Fixed operator+(const Fixed& other) const;
Fixed operator-(const Fixed& other) const;
Fixed operator*(const Fixed& other) const;
Fixed operator/(const Fixed& other) const;
Fixed &operator++();
Fixed operator++(int);
Fixed &operator--();
Fixed operator--(int);
static Fixed &min(Fixed &a, Fixed &b);
static const Fixed &min(const Fixed &a, const Fixed &b);
static Fixed &max(Fixed &a, Fixed &b);
static const Fixed &max(const Fixed &a, const Fixed &b);
};
std::ostream &operator<<(std::ostream &out, const Fixed &fixed);
#endif