- Check *this for zeroness before .invert()ing it.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Fri, 4 Aug 2000 16:36:55 +0000 (16:36 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Fri, 4 Aug 2000 16:36:55 +0000 (16:36 +0000)
ginac/numeric.cpp

index bfa00af6a1b7e81432d3184ec3f4b0c3da70699c..0df296eb944ebb3d558e76e03d95d59f54f84521 100644 (file)
@@ -716,7 +716,7 @@ numeric numeric::mul(const numeric & other) const
 numeric numeric::div(const numeric & other) const
 {
     if (::zerop(*other.value))
-        throw std::overflow_error("division by zero");
+        throw std::overflow_error("numeric::div(): division by zero");
     return numeric((*value)/(*other.value));
 }
 
@@ -741,6 +741,8 @@ numeric numeric::power(const numeric & other) const
 /** Inverse of a number. */
 numeric numeric::inverse(void) const
 {
+    if (::zerop(*value))
+        throw std::overflow_error("numeric::inverse(): division by zero");
     return numeric(::recip(*value));  // -> CLN
 }