summaryrefslogtreecommitdiff
path: root/ex01/Fixed.hpp
diff options
context:
space:
mode:
authorDominik Kaiser2025-02-13 16:41:08 +0100
committerDominik Kaiser2025-02-13 16:41:08 +0100
commit1fff37e7b9b63e5e62e9d9d0eb4535636f7f2fe8 (patch)
tree7ae7a938fbe2a486d7512730f48648ab26f52515 /ex01/Fixed.hpp
parentb013c2457c45d369c9fc9a854caacdffd414ca25 (diff)
downloadcpp02-main.tar.gz
cpp02-main.zip
Add ex01HEADmain
Diffstat (limited to 'ex01/Fixed.hpp')
-rw-r--r--ex01/Fixed.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/ex01/Fixed.hpp b/ex01/Fixed.hpp
new file mode 100644
index 0000000..cb2878e
--- /dev/null
+++ b/ex01/Fixed.hpp
@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* Fixed.hpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2025/02/12 17:05:34 by dkaiser #+# #+# */
+/* Updated: 2025/02/13 16:02:44 by dkaiser ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef FIXED_H_
+#define FIXED_H_
+
+#include <ostream>
+
+class Fixed
+{
+ public:
+ Fixed(void);
+ Fixed(const int i);
+ Fixed(const float f);
+ Fixed(const Fixed &other);
+ Fixed &operator=(const Fixed &other);
+ ~Fixed(void);
+
+ int getRawBits(void) const;
+ void setRawBits(int const raw);
+ int toInt(void) const;
+ float toFloat(void) const;
+
+ private:
+ static const int fractional_bits = 8;
+ int raw_value;
+};
+
+std::ostream &operator<<(std::ostream &os, const Fixed &fixed);
+
+#endif