From 3d48ed0312f9c0ae691560d7cd688f46917e3fd4 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 13 Apr 2020 13:07:19 +0200 Subject: cpp02 base --- cpp02/ex01/Fixed.hpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cpp02/ex01/Fixed.hpp (limited to 'cpp02/ex01/Fixed.hpp') 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 + +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 -- cgit