diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2016-10-28 21:51:33 +0200 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2016-10-28 21:51:33 +0200 |
commit | 4225225d5de516221eb771aacf5cc0615da96787 (patch) | |
tree | 0675d96fd2620a29c76d0913286b2c2964079428 /tests/cxx | |
parent | ffb534049ff90767cd30e562930d67a6529d1908 (diff) | |
download | gmp-4225225d5de516221eb771aacf5cc0615da96787.tar.gz |
Optimize 1/q to call mpq_inv.
Also handle (-1)/q and 0/q. We could test for l == 1 at runtime and not just with __builtin_constant_p, it might be worth it, especially for non-gcc compilers.
Diffstat (limited to 'tests/cxx')
-rw-r--r-- | tests/cxx/t-ops.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/cxx/t-ops.cc b/tests/cxx/t-ops.cc index a86da6036..ecc6bd07f 100644 --- a/tests/cxx/t-ops.cc +++ b/tests/cxx/t-ops.cc @@ -502,6 +502,16 @@ check_mpq (void) mpq_class c; c = a / b; ASSERT_ALWAYS(c == 0.75); } + { + mpq_class one = 1; + mpq_class x(2, 5); + ASSERT_ALWAYS(1 / x == one / x); + ASSERT_ALWAYS(1u / x == one / x); + x = (-1) / x; + ASSERT_ALWAYS(x == -2.5); + ASSERT_ALWAYS(0 / x == 0); + ASSERT_ALWAYS(0u / x == 0); + } // operator<< // operator>> |