diff options
author | Tim King <taking@cs.nyu.edu> | 2018-01-07 16:46:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-07 16:46:16 -0800 |
commit | 20957db27201d594a83e0e5abe77875ed4932faf (patch) | |
tree | 47c665493a2a26d9ad50d2f53de310a7ce8193e0 /src/util/rational_cln_imp.cpp | |
parent | 8497910df4d1c254b26f09c3dc5ee6191c970b12 (diff) |
Removes RationalFromDoubleException. Replaces this with an explicit M… (#1476)
* Removes RationalFromDoubleException. Replaces this with an explicit Maybe<Rational> datatype. Makes Maybe<T> CVC4_PUBLIC. Updates the users of Rational::fromDouble(). Miscellaneous cleanup of ApproxSimplex.
Diffstat (limited to 'src/util/rational_cln_imp.cpp')
-rw-r--r-- | src/util/rational_cln_imp.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/util/rational_cln_imp.cpp b/src/util/rational_cln_imp.cpp index 09e3c8168..6250cbccd 100644 --- a/src/util/rational_cln_imp.cpp +++ b/src/util/rational_cln_imp.cpp @@ -84,29 +84,21 @@ int Rational::absCmp(const Rational& q) const{ } } -Rational Rational::fromDouble(double d) throw(RationalFromDoubleException){ +Maybe<Rational> Rational::fromDouble(double d) +{ try{ cln::cl_DF fromD = d; Rational q; q.d_value = cln::rationalize(fromD); return q; }catch(cln::floating_point_underflow_exception& fpue){ - throw RationalFromDoubleException(d); + return Maybe<Rational>(); }catch(cln::floating_point_nan_exception& fpne){ - throw RationalFromDoubleException(d); + return Maybe<Rational>(); }catch(cln::floating_point_overflow_exception& fpoe){ - throw RationalFromDoubleException(d); + return Maybe<Rational>(); } -} - -RationalFromDoubleException::RationalFromDoubleException(double d) throw() - : Exception() -{ - std::stringstream ss; - ss << "RationalFromDoubleException("; - ss << d; - ss << ")"; - setMessage(ss.str()); + Unreachable(); } } /* namespace CVC4 */ |