aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-09 20:20:14 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-09 20:20:14 +0800
commitdb59e90e97adaacf758bbd5f4cd86ed9b30262d6 (patch)
treef85ae4b0983c37d66da2ea50e44034a692b037d4
parent5eae404fc464674870a73b607a5bdcd8665be27e (diff)
canonicalize the rational number to avoid crash
-rw-r--r--builtin.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/builtin.cpp b/builtin.cpp
index 610cdec..94fcd9b 100644
--- a/builtin.cpp
+++ b/builtin.cpp
@@ -327,6 +327,7 @@ RatNumObj *RatNumObj::from_string(string repr) {
try
{
mpq_class ret(repr, 10);
+ ret.canonicalize();
return new RatNumObj(ret);
}
catch (std::invalid_argument &e)