3
Copyright 2001 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 2.1 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; see the file COPYING.LIB. If not, write to
19
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20
MA 02111-1307, USA. */
30
check_one (mpz_srcptr z)
32
static const int shift[] = {
33
0, 1, BITS_PER_MP_LIMB, 2*BITS_PER_MP_LIMB, 5*BITS_PER_MP_LIMB
40
mpf_init2 (f, mpz_sizeinbase(z,2));
44
for (sh = 0; sh < numberof(shift); sh++)
46
for (shneg = 0; shneg <= 1; shneg++)
48
for (neg = 0; neg <= 1; neg++)
61
mpz_tdiv_q_2exp (want, want, shift[sh]);
62
mpf_div_2exp (f, f, shift[sh]);
66
mpz_mul_2exp (want, want, shift[sh]);
67
mpf_mul_2exp (f, f, shift[sh]);
71
MPZ_CHECK_FORMAT (got);
73
if (mpz_cmp (got, want) != 0)
75
printf ("wrong result\n");
76
printf (" shift %d\n", shneg ? -shift[sh] : shift[sh]);
77
printf (" neg %d\n", neg);
79
mpz_trace (" got", got);
80
mpz_trace (" want", want);
103
mpz_set_si (z, 123L);
106
mpz_rrandomb (z, RANDS, 2*BITS_PER_MP_LIMB);
109
mpz_rrandomb (z, RANDS, 5*BITS_PER_MP_LIMB);
117
main (int argc, char *argv[])