int and float constructor right print

This commit is contained in:
Camille Chauvet 2023-08-07 16:44:03 +02:00
parent 4d3528ed3f
commit 1c500e28bf
3 changed files with 4 additions and 4 deletions

View File

@ -22,13 +22,13 @@ Fixed::Fixed(const Fixed& src)
Fixed::Fixed(const int& src) Fixed::Fixed(const int& src)
{ {
std::cout << "Copy constructor called" << std::endl; std::cout << "Int constructor called" << std::endl;
this->_value = src << this->_nb_bits; this->_value = src << this->_nb_bits;
} }
Fixed::Fixed(const float& src) Fixed::Fixed(const float& src)
{ {
std::cout << "Copy constructor called" << std::endl; std::cout << "Float constructor called" << std::endl;
this->_value = (int) roundf(src * (1 << this->_nb_bits)); this->_value = (int) roundf(src * (1 << this->_nb_bits));
} }

BIN
ex02/ex02 Executable file

Binary file not shown.

View File

@ -22,13 +22,13 @@ Fixed::Fixed(const Fixed& src)
Fixed::Fixed(const int& src) Fixed::Fixed(const int& src)
{ {
std::cout << "Copy constructor called" << std::endl; std::cout << "Int constructor called" << std::endl;
this->_value = src << this->_nb_bits; this->_value = src << this->_nb_bits;
} }
Fixed::Fixed(const float& src) Fixed::Fixed(const float& src)
{ {
std::cout << "Copy constructor called" << std::endl; std::cout << "Float constructor called" << std::endl;
this->_value = (int) roundf(src * (1 << this->_nb_bits)); this->_value = (int) roundf(src * (1 << this->_nb_bits));
} }