1 /* Test mpn_scan0 and mpn_scan1.
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 #define SIZE ((mp_size_t) 3)
35 unsigned long i, got, want;
38 for (i = 0; i < SIZE*GMP_NUMB_BITS; i++)
40 got = refmpn_scan1 (x, i);
41 want = mpn_scan1 (x, i);
44 printf ("mpn_scan1\n");
45 printf (" i %lu\n", i);
46 printf (" got %lu\n", got);
47 printf (" want %lu\n", want);
48 mpn_trace (" x ", x, SIZE);
54 for (i = 0; i < SIZE*GMP_NUMB_BITS; i++)
56 got = refmpn_scan0 (x, i);
57 want = mpn_scan0 (x, i);
60 printf ("mpn_scan0\n");
61 printf (" i %lu\n", i);
62 printf (" got %lu\n", got);
63 printf (" want %lu\n", want);
64 mpn_trace (" x ", x, SIZE);
73 #define TWOBITS(a, b) \
74 ((CNST_LIMB(1) << (a)) | (CNST_LIMB(1) << (b)))
76 refmpn_zero (x, SIZE);
77 x[0] = TWOBITS (1, 0);
80 refmpn_zero (x, SIZE);
81 x[0] = TWOBITS (GMP_NUMB_BITS-1, 1);
84 refmpn_zero (x, SIZE);
89 refmpn_zero (x, SIZE);
90 x[0] = CNST_LIMB(1) << (GMP_NUMB_BITS-1);
94 refmpn_zero (x, SIZE);
95 x[1] = TWOBITS (1, 0);
98 refmpn_zero (x, SIZE);
104 /* This is unused, it takes too long, especially on 64-bit systems. */
106 check_twobits_exhaustive (void)
110 for (i = 0; i < GMP_NUMB_BITS * SIZE; i++)
112 for (j = 0; j < GMP_NUMB_BITS * SIZE; j++)
114 refmpn_zero (x, SIZE);
115 refmpn_setbit (x, i);
116 refmpn_setbit (x, j);
127 for (i = 0; i < 100; i++)
129 refmpn_random2 (x, SIZE);