ui_pow_ui.c revision 1.1.1.1
1/* mpz_ui_pow_ui -- ulong raised to ulong.
2
3Copyright 2001, 2002 Free Software Foundation, Inc.
4
5This file is part of the GNU MP Library.
6
7The GNU MP Library is free software; you can redistribute it and/or modify
8it under the terms of the GNU Lesser General Public License as published by
9the Free Software Foundation; either version 3 of the License, or (at your
10option) any later version.
11
12The GNU MP Library is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15License for more details.
16
17You should have received a copy of the GNU Lesser General Public License
18along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
19
20#include "gmp.h"
21#include "gmp-impl.h"
22
23
24void
25mpz_ui_pow_ui (mpz_ptr r, unsigned long b, unsigned long e)
26{
27#if GMP_NAIL_BITS != 0
28  if (b > GMP_NUMB_MAX)
29    {
30      mp_limb_t bb[2];
31      bb[0] = b & GMP_NUMB_MASK;
32      bb[1] = b >> GMP_NUMB_BITS;
33      mpz_n_pow_ui (r, bb, (mp_size_t) 2, e);
34    }
35  else
36#endif
37    {
38#ifdef _LONG_LONG_LIMB
39      /* i386 gcc 2.95.3 doesn't recognise blimb can be eliminated when
40	 mp_limb_t is an unsigned long, so only use a separate blimb when
41	 necessary.  */
42      mp_limb_t  blimb = b;
43      mpz_n_pow_ui (r, &blimb, (mp_size_t) (b != 0), e);
44#else
45      mpz_n_pow_ui (r, &b,     (mp_size_t) (b != 0), e);
46#endif
47    }
48}
49