1 /* mpz_mul_ui/si (product, multiplier, small_multiplicand) -- Set PRODUCT to
2 MULTIPLICATOR times SMALL_MULTIPLICAND.
4 Copyright (C) 1991, 1993, 1994, 1996, 2000 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 2.1 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; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 MA 02111-1307, USA. */
27 #ifdef OPERATION_mul_ui
28 #define FUNCTION mpz_mul_ui
29 #define MULTIPLICAND_UNSIGNED unsigned
30 #define MULTIPLICAND_ABS(x) x
32 #ifdef OPERATION_mul_si
33 #define FUNCTION mpz_mul_si
34 #define MULTIPLICAND_UNSIGNED
35 #define MULTIPLICAND_ABS(x) ABS(x)
37 Error, error, unrecognised OPERATION
44 FUNCTION (mpz_ptr prod, mpz_srcptr mult,
45 MULTIPLICAND_UNSIGNED long int small_mult)
47 FUNCTION (prod, mult, small_mult)
50 MULTIPLICAND_UNSIGNED long int small_mult;
53 mp_size_t size = mult->_mp_size;
54 mp_size_t sign_product = size;
59 if (size == 0 || small_mult == 0)
67 if (prod->_mp_alloc < prod_size)
68 _mpz_realloc (prod, prod_size);
70 prod_ptr = prod->_mp_d;
72 cy = mpn_mul_1 (prod_ptr, mult->_mp_d, size,
73 (mp_limb_t) MULTIPLICAND_ABS (small_mult));
80 prod->_mp_size = ((sign_product < 0) ^ (small_mult < 0)) ? -size : size;