diff options
author | Kevin Ryde <user42@zip.com.au> | 2002-06-29 02:10:48 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2002-06-29 02:10:48 +0200 |
commit | 357b7d4733c43d085f68bdc6cebe86965e9d0dc1 (patch) | |
tree | 4c6937723e133b41e2c0377dcd77221b87dc6c4e /tests/t-constants.c | |
parent | 42ed894f30899adfb25426db0049700a6786f210 (diff) | |
download | gmp-357b7d4733c43d085f68bdc6cebe86965e9d0dc1.tar.gz |
* gmp-impl.h (MODLIMB_INVERSE_3): Allow for GMP_NUMB_BITS odd.
(GMP_NUMB_CEIL_MAX_DIV3, GMP_NUMB_CEIL_2MAX_DIV3): New constants.
* tests/t-constants.c: Check them.
Diffstat (limited to 'tests/t-constants.c')
-rw-r--r-- | tests/t-constants.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/tests/t-constants.c b/tests/t-constants.c index 455412ce7..a8d025f15 100644 --- a/tests/t-constants.c +++ b/tests/t-constants.c @@ -22,6 +22,8 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include "gmp.h" +#include "tests.h" + #ifdef ULONG_MAX char *ulong_max_def = "defined"; @@ -245,19 +247,55 @@ main (int argc, char *argv[]) CHECK_CONDITION (2*bits_per_UHWtype >= bits_per_UWtype); } + ASSERT_ALWAYS_LIMB (MODLIMB_INVERSE_3); { mp_limb_t modlimb_inverse_3_calc; modlimb_invert (modlimb_inverse_3_calc, CNST_LIMB(3)); - CHECK_LIMB (MODLIMB_INVERSE_3 & GMP_NUMB_MASK, - modlimb_inverse_3_calc & GMP_NUMB_MASK); + ASSERT_ALWAYS_LIMB (modlimb_inverse_3_calc); + CHECK_LIMB (MODLIMB_INVERSE_3, modlimb_inverse_3_calc); } - { mp_limb_t MODLIMB_INVERSE_3_times_3 = (MODLIMB_INVERSE_3 * CNST_LIMB(3)) & GMP_NUMB_MASK; CHECK_LIMB (MODLIMB_INVERSE_3_times_3, CNST_LIMB(1)); } + { + mp_limb_t hi, lo; + hi = refmpn_umul_ppmm (&lo, GMP_NUMB_CEIL_MAX_DIV3-1, + CNST_LIMB(3) << GMP_NAIL_BITS); + if (! (hi < 1)) + { + printf ("GMP_NUMB_CEIL_MAX_DIV3 too big\n"); + error = 1; + } + hi = refmpn_umul_ppmm (&lo, GMP_NUMB_CEIL_MAX_DIV3, + CNST_LIMB(3) << GMP_NAIL_BITS); + if (! (hi >= 1)) + { + printf ("GMP_NUMB_CEIL_MAX_DIV3 too small\n"); + error = 1; + } + } + + { + mp_limb_t hi, lo; + hi = refmpn_umul_ppmm (&lo, GMP_NUMB_CEIL_2MAX_DIV3-1, + CNST_LIMB(3) << GMP_NAIL_BITS); + if (! (hi < 2)) + { + printf ("GMP_NUMB_CEIL_2MAX_DIV3 too big\n"); + error = 1; + } + hi = refmpn_umul_ppmm (&lo, GMP_NUMB_CEIL_2MAX_DIV3, + CNST_LIMB(3) << GMP_NAIL_BITS); + if (! (hi >= 2)) + { + printf ("GMP_NUMB_CEIL_2MAX_DIV3 too small\n"); + error = 1; + } + } + #ifdef PP_INVERTED { mp_limb_t pp_inverted_calc; |