1 /* Check mp_bases values.
3 Copyright 2002 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
7 The GNU MP Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
12 The GNU MP Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
29 main (int argc, char *argv[])
31 mp_limb_t want_bb, want_bb_inv;
32 int base, want_chars_per_limb;
34 want_chars_per_limb = refmpn_chars_per_limb (10);
35 if (MP_BASES_CHARS_PER_LIMB_10 != want_chars_per_limb)
37 printf ("MP_BASES_CHARS_PER_LIMB_10 wrong\n");
41 want_bb = refmpn_big_base (10);
42 if (MP_BASES_BIG_BASE_10 != want_bb)
44 printf ("MP_BASES_BIG_BASE_10 wrong\n");
48 want_bb_inv = refmpn_invert_limb
49 (want_bb << refmpn_count_leading_zeros (want_bb));
50 if (MP_BASES_BIG_BASE_INVERTED_10 != want_bb_inv)
52 printf ("MP_BASES_BIG_BASE_INVERTED_10 wrong\n");
56 if (MP_BASES_NORMALIZATION_STEPS_10
57 != refmpn_count_leading_zeros (MP_BASES_BIG_BASE_10))
59 printf ("MP_BASES_NORMALIZATION_STEPS_10 wrong\n");
63 for (base = 2; base < numberof (mp_bases); base++)
65 want_chars_per_limb = refmpn_chars_per_limb (base);
66 if (mp_bases[base].chars_per_limb != want_chars_per_limb)
68 printf ("mp_bases[%d].chars_per_limb wrong\n", base);
69 printf (" got %d\n", mp_bases[base].chars_per_limb);
70 printf (" want %d\n", want_chars_per_limb);
76 want_bb = refmpn_count_trailing_zeros ((mp_limb_t) base);
77 if (mp_bases[base].big_base != want_bb)
79 printf ("mp_bases[%d].big_base (log2 of base) wrong\n", base);
85 want_bb = refmpn_big_base (base);
86 if (mp_bases[base].big_base != want_bb)
88 printf ("mp_bases[%d].big_base wrong\n", base);
92 #if USE_PREINV_DIVREM_1
93 want_bb_inv = refmpn_invert_limb
94 (want_bb << refmpn_count_leading_zeros (want_bb));
95 if (mp_bases[base].big_base_inverted != want_bb_inv)
97 printf ("mp_bases[%d].big_base_inverted wrong\n", base);