projects
/
42
/
CPP_Module_02
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d1bd173
)
Add rounding in float constructor
author
Lukas Jiriste
<ljiriste@student.42prague.com>
Thu, 17 Oct 2024 11:54:58 +0000
(13:54 +0200)
committer
Lukas Jiriste
<ljiriste@student.42prague.com>
Thu, 17 Oct 2024 11:54:58 +0000
(13:54 +0200)
ex01/Fixed.cpp
patch
|
blob
|
history
diff --git
a/ex01/Fixed.cpp
b/ex01/Fixed.cpp
index 8f5ceb4eea333c8a3f06ff14caf2c15ad7e74c2d..ce732a8c88ccbfdbe0a01fb8892ee3b9515ac79e 100644
(file)
--- a/
ex01/Fixed.cpp
+++ b/
ex01/Fixed.cpp
@@
-1,4
+1,5
@@
#include "Fixed.h"
+#include <cmath>
#include <iostream>
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";
}