summaryrefslogtreecommitdiff
path: root/pow.c
diff options
context:
space:
mode:
authorhanrot <hanrot@280ebfd0-de03-0410-8827-d642c229c3f4>2000-11-21 15:21:33 +0000
committerhanrot <hanrot@280ebfd0-de03-0410-8827-d642c229c3f4>2000-11-21 15:21:33 +0000
commitebb0a24940eb551ce03eb361910c423fee7d6499 (patch)
tree46fccc5920d05d93d00ecd30aff4a012adba3d13 /pow.c
parent1cc85c4f5a5658c530891f7348c153155b6dddbb (diff)
downloadmpfr-ebb0a24940eb551ce03eb361910c423fee7d6499.tar.gz
Infinis, premiere tentative.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@793 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'pow.c')
-rw-r--r--pow.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/pow.c b/pow.c
index 7b1b74336..cb7204e0f 100644
--- a/pow.c
+++ b/pow.c
@@ -38,7 +38,16 @@ mpfr_pow_ui (x, y, n, rnd)
#endif
{
long int i; double err;
-
+
+ if (MPFR_IS_INF(y))
+ {
+ if (n == 0) { MPFR_SET_NAN(x); return; }
+ else if ((MPFR_SIGN(y) < 0 && (MPFR_SIGN(x) > 0 || n % 2 == 0)) ||
+ MPFR_SIGN(y) > 0 && (MPFR_SIGN(x) < 0 && n % 2 == 1))
+ MPFR_CHANGE_SIGN(x);
+ MPFR_SET_INF(x); return;
+ }
+
if (n==0) { mpfr_set_ui(x, 1, rnd); return 0; }
mpfr_set(x, y, rnd); err = 1.0;
for (i=0;(1<<i)<=n;i++);
@@ -51,6 +60,10 @@ mpfr_pow_ui (x, y, n, rnd)
}
/* sets x to y^n, and returns ceil(log2(max ulp error)) */
+
+/* TODO: gerer l'infini en cas de debordement ? Fait mecaniquement si fait
+ dans mul ? */
+
int
#if __STDC__
mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int y, unsigned long int n,