aboutsummaryrefslogtreecommitdiff
path: root/cpp02
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-08 13:39:12 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-08 13:39:12 +0100
commit1e9d90bdf9ef5fc05093d3449d883597c7f896de (patch)
treecc5334baec6ec10a0d99bc925499512bc44f2cd0 /cpp02
parentc426fe76ec5925e8c94aae3db04e5e1f1ce1585e (diff)
downloadpiscine_cpp-1e9d90bdf9ef5fc05093d3449d883597c7f896de.tar.gz
piscine_cpp-1e9d90bdf9ef5fc05093d3449d883597c7f896de.tar.bz2
piscine_cpp-1e9d90bdf9ef5fc05093d3449d883597c7f896de.zip
Added cpp06 boilerplate
Diffstat (limited to 'cpp02')
-rw-r--r--cpp02/ex01/Fixed.cpp4
-rw-r--r--cpp02/ex01/Fixed.hpp6
2 files changed, 6 insertions, 4 deletions
diff --git a/cpp02/ex01/Fixed.cpp b/cpp02/ex01/Fixed.cpp
index 755a6ae..a81c1cf 100644
--- a/cpp02/ex01/Fixed.cpp
+++ b/cpp02/ex01/Fixed.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 11:45:18 by charles #+# #+# */
-/* Updated: 2020/10/19 11:29:39 by cacharle ### ########.fr */
+/* Updated: 2020/11/08 13:38:40 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -64,7 +64,7 @@ float Fixed::toFloat() const
int Fixed::toInt() const
{
- return m_value >> m_fractionalBits;
+ return roundf(toFloat());
}
int Fixed::getFractionalBits()
diff --git a/cpp02/ex01/Fixed.hpp b/cpp02/ex01/Fixed.hpp
index 726b810..a262c59 100644
--- a/cpp02/ex01/Fixed.hpp
+++ b/cpp02/ex01/Fixed.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 11:40:49 by charles #+# #+# */
-/* Updated: 2020/10/19 11:29:30 by cacharle ### ########.fr */
+/* Updated: 2020/11/08 13:38:48 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -30,13 +30,15 @@ public:
int getRawBits() const;
void setRawBits(int const raw);
+ int getRawBits() const;
+ void setRawBits(int const raw);
float toFloat() const;
int toInt() const;
static int getFractionalBits();
private:
- int m_value;
+ int m_value;
static int const m_fractionalBits = 8;
};