diff options
author | enge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2010-06-17 17:40:38 +0000 |
---|---|---|
committer | enge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2010-06-17 17:40:38 +0000 |
commit | 8f669fde281f3512784a5c53e3c8a1a87e5c283d (patch) | |
tree | 80af8ef84f59bcb51d8a51720b64edfc699035e5 /src/pow_si.c | |
parent | cdae67dc9bf52fd118eff5ea82462fef46691143 (diff) | |
download | mpc-8f669fde281f3512784a5c53e3c8a1a87e5c283d.tar.gz |
unified computation of pow_ui and pow_si in a function pow_usi, thereby
applying binary exponentiation in the case of negative exponent
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@788 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src/pow_si.c')
-rw-r--r-- | src/pow_si.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/pow_si.c b/src/pow_si.c index c7f3957..4b16245 100644 --- a/src/pow_si.c +++ b/src/pow_si.c @@ -19,22 +19,13 @@ along with the MPC Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <limits.h> /* for CHAR_BIT */ #include "mpc-impl.h" int mpc_pow_si (mpc_ptr z, mpc_srcptr x, long y, mpc_rnd_t rnd) { if (y >= 0) - return mpc_pow_ui (z, x, (unsigned long) y, rnd); - else { - mpc_t yy; - int inex; - - mpc_init3 (yy, sizeof (unsigned long) * CHAR_BIT, MPFR_PREC_MIN); - mpc_set_si (yy, y, MPC_RNDNN); /* exact */ - inex = mpc_pow (z, x, yy, rnd); - mpc_clear (yy); - return inex; - } + return mpc_pow_usi (z, x, (unsigned long) y, 1, rnd); + else + return mpc_pow_usi (z, x, (unsigned long) (-y), -1, rnd); } |