aboutsummaryrefslogtreecommitdiff
path: root/cpp02/ex01/Fixed.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp02/ex01/Fixed.hpp')
-rw-r--r--cpp02/ex01/Fixed.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/cpp02/ex01/Fixed.hpp b/cpp02/ex01/Fixed.hpp
new file mode 100644
index 0000000..2dd2d7d
--- /dev/null
+++ b/cpp02/ex01/Fixed.hpp
@@ -0,0 +1,44 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* Fixed.hpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/13 11:40:49 by charles #+# #+# */
+/* Updated: 2020/04/13 12:58:33 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef FIXED_HPP
+# define FIXED_HPP
+
+# include <iostream>
+
+class Fixed
+{
+public:
+ Fixed();
+ Fixed(Fixed const& other);
+ ~Fixed();
+ void operator=(Fixed const& other);
+
+ Fixed(int from);
+ Fixed(float from);
+
+ int getRawBits() const;
+ void setRawBits(int const raw);
+
+ float toFloat() const;
+ int toInt() const;
+
+ static int getFractionalBits();
+
+private:
+ int m_value;
+ static int const m_fractionalBits = 8;
+};
+
+std::ostream& operator<<(std::ostream& out, Fixed const& f);
+
+#endif