diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-04-13 13:07:19 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-04-13 13:07:19 +0200 |
| commit | 3d48ed0312f9c0ae691560d7cd688f46917e3fd4 (patch) | |
| tree | a9ad6b750bfef47e91f85be187ed5a27edd2bd9c /cpp02/ex01/Fixed.hpp | |
| parent | 0f3240844dbd5a874e1565a988ef355ededab6a5 (diff) | |
| download | piscine_cpp-3d48ed0312f9c0ae691560d7cd688f46917e3fd4.tar.gz piscine_cpp-3d48ed0312f9c0ae691560d7cd688f46917e3fd4.tar.bz2 piscine_cpp-3d48ed0312f9c0ae691560d7cd688f46917e3fd4.zip | |
cpp02 base
Diffstat (limited to 'cpp02/ex01/Fixed.hpp')
| -rw-r--r-- | cpp02/ex01/Fixed.hpp | 44 |
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 |
