]> www.ginac.de Git - ginac.git/commitdiff
Fix algebraic power::has() for larger integer exponents.
authorRichard Kreckel <kreckel@ginac.de>
Sat, 10 Oct 2015 09:02:17 +0000 (11:02 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Sat, 10 Oct 2015 09:02:17 +0000 (11:02 +0200)
There is no need to overflow integers in (x^2147483648).has(x^2).

ginac/power.cpp

index 1a4f57dbfe142741fc6117044f3c778673eb3389..8ec6380bcbd522cbabb7d8664905c79aed7e6fc3 100644 (file)
@@ -627,14 +627,12 @@ bool power::has(const ex & other, unsigned options) const
                return basic::has(other, options);
        if (exponent.info(info_flags::posint)
                        && other.op(1).info(info_flags::posint)
-                       && ex_to<numeric>(exponent).to_int()
-                                       > ex_to<numeric>(other.op(1)).to_int()
+                       && ex_to<numeric>(exponent) > ex_to<numeric>(other.op(1))
                        && basis.match(other.op(0)))
                return true;
        if (exponent.info(info_flags::negint)
                        && other.op(1).info(info_flags::negint)
-                       && ex_to<numeric>(exponent).to_int()
-                                       < ex_to<numeric>(other.op(1)).to_int()
+                       && ex_to<numeric>(exponent) < ex_to<numeric>(other.op(1))
                        && basis.match(other.op(0)))
                return true;
        return basic::has(other, options);