From 386487237fc75ae3e8bffef5dde692a971679477 Mon Sep 17 00:00:00 2001 From: jbj Date: Sat, 17 May 2003 02:54:40 +0000 Subject: [PATCH] SPecial cases for negatives to odd positive powers. CVS patchset: 6852 CVS date: 2003/05/17 02:54:40 --- python/mpw/test/test_methods.py | 5 +++-- python/rpmmpw-py.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/python/mpw/test/test_methods.py b/python/mpw/test/test_methods.py index 7ac4c5b..5c73877 100644 --- a/python/mpw/test/test_methods.py +++ b/python/mpw/test/test_methods.py @@ -161,11 +161,11 @@ class BasicTestCase(unittest.TestCase): print '\n', '-=' * 30 print "Running %s.test03_Signs..." % \ self.__class__.__name__ - wp = rpm.mpw(10) + wp = rpm.mpw(11) wm = -wp wpp = wp + 1 wmm = -wpp - zp = long(10) + zp = long(11) zm = -zp zpp = zp + 1 zmm = -zpp @@ -185,6 +185,7 @@ class BasicTestCase(unittest.TestCase): print "div -+:\t", (wm/wp), "\t", (zm/zp) print "div +-:\t", (wp/wm), "\t", (zp/zm) print "div ++:\t", (wp/wp), "\t", (zp/zp) + print "pow --:\t", (wm**wm), "\t", (zm**zm) print "pow -+:\t", (wm**wp), "\t", (zm**zp) print "pow +-:\t", (wp**wm), "\t", (zp**zm) diff --git a/python/rpmmpw-py.c b/python/rpmmpw-py.c index 4be45db..c032ee0 100644 --- a/python/rpmmpw-py.c +++ b/python/rpmmpw-py.c @@ -1539,10 +1539,12 @@ fprintf(stderr, "sub ++: borrow\n"); mpnzero(&zn); if (msize == 0 || (msize == 1 && *mdata == 0)) mpnsetw(&zn, 1); - else if (m->ob_size < 0) + else if (mpz(xsize, xdata) || m->ob_size < 0) mpnsetw(&zn, 0); - else + else { + zsign = (x->ob_size > 0 || mpeven(msize, mdata)) ? 1 : -1; mpnpow_w(&zn, xsize, xdata, msize, mdata); + } z = mpw_FromMPW(zn.size, zn.data, 1); mpnfree(&zn); if (zsign < 0) -- 2.7.4