]> www.ginac.de Git - ginac.git/blobdiff - ginac/numeric.cpp
- Check *this for zeroness before .invert()ing it.
[ginac.git] / 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
 }