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