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 1a4f57d..8ec6380 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);