CPP02 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Fixed.hpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* Fixed.hpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/04/26 22:12:12 by kamitsui #+# #+# */
9/* Updated: 2025/05/06 15:10:52 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
26#ifndef FIXED_HPP
27#define FIXED_HPP
28
29#include <iostream>
30
34class Fixed {
35 private:
36 int fixedPointValue;
37 static const int fractionalBits = 8;
38
39 public:
41
45 Fixed(const int raw);
46
50 Fixed(const float raw);
51
52 Fixed(const Fixed &other);
53
57 Fixed &operator=(const Fixed &other);
58
60
61 int getRawBits(void) const;
62 void setRawBits(int const raw);
63
67 float toFloat(void) const;
68
72 int toInt(void) const;
73};
74
79std::ostream &operator<<(std::ostream &o, const Fixed &fixed);
80
81#endif
ex00 Fixed Class
Definition Fixed.hpp:28
int toInt(void) const
Converts the fixed-point value to an integer value (truncates the fractional part).
Definition Fixed.cpp:101
int getRawBits(void) const
void setRawBits(int const raw)
Fixed(const Fixed &other)
Fixed & operator=(const Fixed &other)
Copy assignment operator.
float toFloat(void) const
Converts the fixed-point value to a floating-point value.
Definition Fixed.cpp:92
std::ostream & operator<<(std::ostream &o, const Fixed &fixed)
Overloads the output stream operator to insert the float representation of the fixed-point number int...
Definition Fixed.cpp:113