1 /* Test mpz_mul, mpz_divexact.
3 Copyright 1996, 2001, 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/. */
28 main (int argc, char **argv)
35 gmp_randstate_ptr rands;
37 unsigned long bsi, size_range;
40 TESTS_REPS (reps, argv, argc);
53 for (i = 0; i < reps; i++)
55 mpz_urandomb (bs, rands, 32);
56 size_range = mpz_get_ui (bs) % 17 + 2; /* 0..2047 bit operands */
58 mpz_urandomb (bs, rands, size_range);
59 size = mpz_get_ui (bs);
60 mpz_rrandomb (op1, rands, size);
64 mpz_urandomb (bs, rands, size_range);
65 size = mpz_get_ui (bs);
66 mpz_rrandomb (op2, rands, size);
68 while (mpz_sgn (op2) == 0);
70 mpz_urandomb (bs, rands, 2);
71 bsi = mpz_get_ui (bs);
77 mpz_mul (prod, op1, op2);
79 mpz_divexact (quot, prod, op2);
80 MPZ_CHECK_FORMAT (quot);
82 if (mpz_cmp (quot, op1) != 0)
84 printf ("Wrong results:\n");
85 mpz_trace (" got ", quot);
86 mpz_trace (" want ", op1);
87 mpz_trace (" dividend", prod);
88 mpz_trace (" divisor ", op2);