1 /* test mpz_divisible_2exp_p */
4 Copyright 2001 Free Software Foundation, Inc.
6 This file is part of the GNU MP Library.
8 The GNU MP Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
13 The GNU MP Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
30 check_one (mpz_srcptr a, unsigned long d, int want)
34 got = (mpz_divisible_2exp_p (a, d) != 0);
37 printf ("mpz_divisible_2exp_p wrong\n");
38 printf (" expected %d got %d\n", want, got);
40 printf (" d=%lu\n", d);
43 printf (" d=0x%lX\n", d);
76 { "0x80000000", 31, 1 },
77 { "0x80000000", 32, 0 },
78 { "0x80000000", 64, 0 },
80 { "0x100000000", 32, 1 },
81 { "0x100000000", 33, 0 },
82 { "0x100000000", 64, 0 },
84 { "0x8000000000000000", 63, 1 },
85 { "0x8000000000000000", 64, 0 },
86 { "0x8000000000000000", 128, 0 },
88 { "0x10000000000000000", 64, 1 },
89 { "0x10000000000000000", 65, 0 },
90 { "0x10000000000000000", 128, 0 },
91 { "0x10000000000000000", 256, 0 },
93 { "0x10000000000000000100000000", 32, 1 },
94 { "0x10000000000000000100000000", 33, 0 },
95 { "0x10000000000000000100000000", 64, 0 },
97 { "0x1000000000000000010000000000000000", 64, 1 },
98 { "0x1000000000000000010000000000000000", 65, 0 },
99 { "0x1000000000000000010000000000000000", 128, 0 },
100 { "0x1000000000000000010000000000000000", 256, 0 },
101 { "0x1000000000000000010000000000000000", 1024, 0 },
111 for (i = 0; i < numberof (data); i++)
113 mpz_set_str_or_abort (a, data[i].a, 0);
114 check_one (a, data[i].d, data[i].want);
117 check_one (a, data[i].d, data[i].want);
125 main (int argc, char *argv[])