Esempio n. 1
0
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;
}
Esempio n. 2
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); 
}
Esempio n. 3
0
Fixed::Fixed(const Fixed& n) :
    _fixed(n.getRawBits()),
    _fractional(8)
{
    std::cout << "Copy constructor called" << std::endl;
}
Esempio n. 4
0
bool		Fixed::operator!=(Fixed const & rhs) {
	return this->_n != rhs.getRawBits();
}
Esempio n. 5
0
bool					Fixed::operator!=(Fixed const & rhs)
{
	return (getRawBits() != rhs.getRawBits() ? true : false);
}	
Esempio n. 6
0
Fixed					Fixed::operator/(Fixed const & rhs)
{
	if (rhs.getRawBits() == 0)
		return (Fixed(0));
	return(Fixed(toFloat() / rhs.toFloat()));
}
Esempio n. 7
0
Fixed Fixed::operator-(Fixed const &rhs) {
	Fixed newFixe = Fixed(this->getRawBits() - rhs.getRawBits());
	return newFixe;
}
Esempio n. 8
0
bool Fixed::operator!=(Fixed const &rhs) const{
	if (this->getRawBits() != rhs.getRawBits())
		return true;
	return false;
}
Esempio n. 9
0
Fixed::Fixed(Fixed const &src) {
	std::cout << "Copy constructor called" << std::endl;
	_value = src.getRawBits();
}