From: Lukas Jiriste Date: Thu, 17 Oct 2024 11:54:58 +0000 (+0200) Subject: Add rounding in float constructor X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=44f763d99b96e8bb239803414957fdf770c5ff88;p=42%2FCPP_Module_02 Add rounding in float constructor --- diff --git a/ex01/Fixed.cpp b/ex01/Fixed.cpp index 8f5ceb4..ce732a8 100644 --- a/ex01/Fixed.cpp +++ b/ex01/Fixed.cpp @@ -1,4 +1,5 @@ #include "Fixed.h" +#include #include Fixed::Fixed(): m_num(0) @@ -10,7 +11,7 @@ Fixed::Fixed(const int init): m_num(init << point_pos) { std::cout << "Int constructor called\n"; } -Fixed::Fixed(const float init): m_num(init * (1 << point_pos)) +Fixed::Fixed(const float init): m_num(roundf(init * (1 << point_pos))) { std::cout << "Float constructor called\n"; }