summaryrefslogtreecommitdiff
path: root/gmpxx.h
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2018-02-28 08:18:49 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2018-02-28 08:18:49 +0100
commit1365b59a8e61268351ede67b1366e566b2ddf721 (patch)
treebdf6954f7d75a5a1193fe466c0f3c4fb45b82593 /gmpxx.h
parent42999d0118a17862770a9bbe2e752d9917d9f959 (diff)
downloadgmp-1365b59a8e61268351ede67b1366e566b2ddf721.tar.gz
gmpxx.h (__gmp_binary_{min,pl}us): Special case for mpq -/+ 1.
Diffstat (limited to 'gmpxx.h')
-rw-r--r--gmpxx.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/gmpxx.h b/gmpxx.h
index 42d331658..3d778689a 100644
--- a/gmpxx.h
+++ b/gmpxx.h
@@ -220,6 +220,11 @@ struct __gmp_binary_plus
{
if (q != r) mpq_set(q, r);
}
+ else if (__GMPXX_CONSTANT(l) && l == 1)
+ {
+ mpz_add (mpq_numref(q), mpq_numref(r), mpq_denref(r));
+ if (q != r) mpz_set(mpq_denref(q), mpq_denref(r));
+ }
else
{
if (q == r)
@@ -339,6 +344,11 @@ struct __gmp_binary_minus
{
if (q != r) mpq_set(q, r);
}
+ else if (__GMPXX_CONSTANT(l) && l == 1)
+ {
+ mpz_sub (mpq_numref(q), mpq_numref(r), mpq_denref(r));
+ if (q != r) mpz_set(mpq_denref(q), mpq_denref(r));
+ }
else
{
if (q == r)