int main(void) { Fixed a; Fixed b( a ); Fixed c; c = b; std::cout << a.getRawBits() << std::endl; std::cout << b.getRawBits() << std::endl; std::cout << c.getRawBits() << std::endl; return 0; }
Fixed Fixed::operator*(Fixed const &rhs) { Fixed f; int result; result = this->_fixe * rhs.getRawBits(); result += 1 << (this->_fractionalbits - 1); result >>= this->_fractionalbits; f.setRawBits(result); return (f); }
Fixed::Fixed(const Fixed& n) : _fixed(n.getRawBits()), _fractional(8) { std::cout << "Copy constructor called" << std::endl; }
bool Fixed::operator!=(Fixed const & rhs) { return this->_n != rhs.getRawBits(); }
bool Fixed::operator!=(Fixed const & rhs) { return (getRawBits() != rhs.getRawBits() ? true : false); }
Fixed Fixed::operator/(Fixed const & rhs) { if (rhs.getRawBits() == 0) return (Fixed(0)); return(Fixed(toFloat() / rhs.toFloat())); }
Fixed Fixed::operator-(Fixed const &rhs) { Fixed newFixe = Fixed(this->getRawBits() - rhs.getRawBits()); return newFixe; }
bool Fixed::operator!=(Fixed const &rhs) const{ if (this->getRawBits() != rhs.getRawBits()) return true; return false; }
Fixed::Fixed(Fixed const &src) { std::cout << "Copy constructor called" << std::endl; _value = src.getRawBits(); }