d02 ex02 ajout protection division par 0
This commit is contained in:
@@ -141,6 +141,9 @@ Fixed Fixed::operator* ( Fixed const & rhs ) const {
|
|||||||
}
|
}
|
||||||
Fixed Fixed::operator/ ( Fixed const & rhs ) const {
|
Fixed Fixed::operator/ ( Fixed const & rhs ) const {
|
||||||
Fixed result(*this);
|
Fixed result(*this);
|
||||||
|
if (rhs.value == 0)
|
||||||
|
std::cout << "impossible division by 0\n";
|
||||||
|
else
|
||||||
result._value = (long)(result._value << Fixed::_frac) / rhs._value;
|
result._value = (long)(result._value << Fixed::_frac) / rhs._value;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user