summaryrefslogtreecommitdiff
path: root/zeta.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-04-11 10:08:39 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-04-11 10:08:39 +0000
commit6b9c30c99d8ad35d39b5481fbb3a67860f4264cd (patch)
treeee867e9454f2275579e4edada94ba2ac584ffc9a /zeta.c
parentabb678c619e2637428f0fd19f800ebb26f12712b (diff)
downloadmpfr-6b9c30c99d8ad35d39b5481fbb3a67860f4264cd.tar.gz
moved test for NaN/Inf
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2290 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'zeta.c')
-rw-r--r--zeta.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/zeta.c b/zeta.c
index 2cb7d7395..3407e76a3 100644
--- a/zeta.c
+++ b/zeta.c
@@ -154,7 +154,8 @@ mpfr_zeta_part_a (mpfr_t sum, mpfr_srcptr s, int n)
}
/* Input: s - a floating-point number >= 1/2.
- rnd_mode - a rounding mode
+ rnd_mode - a rounding mode.
+ Assumes s is neither NaN nor Infinite.
Output: z - Zeta(s) rounded to the precision of z with direction rnd_mode
*/
void
@@ -166,26 +167,6 @@ mpfr_zeta_pos (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode)
mpfr_t *tc1;
mp_prec_t precz, precs;
- if (mpfr_nan_p (s))
- {
- mpfr_set_nan (z); /* Zeta(NaN) = NaN */
- return;
- }
-
- if (mpfr_inf_p (s))
- {
- if (MPFR_SIGN(s) > 0)
- {
- mpfr_set_ui (z, 1, GMP_RNDN); /* Zeta(+Inf) = 1 */
- return;
- }
- else
- {
- mpfr_set_nan (z); /* Zeta(-Inf) = NaN */
- return;
- }
- }
-
precz = mpfr_get_prec (z);
precs = mpfr_get_prec (s);
@@ -332,6 +313,28 @@ mpfr_zeta (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode)
mpfr_t z_pre, s1, s2, y, sfrac, sint, p;
mp_prec_t precz, prec1, precs, precs1;
+ if (mpfr_nan_p (s))
+ {
+ mpfr_set_nan (z); /* Zeta(NaN) = NaN */
+ return;
+ }
+
+ if (mpfr_inf_p (s))
+ {
+ if (MPFR_SIGN(s) > 0)
+ {
+ mpfr_set_ui (z, 1, GMP_RNDN); /* Zeta(+Inf) = 1 */
+ return;
+ }
+ else
+ {
+ mpfr_set_nan (z); /* Zeta(-Inf) = NaN */
+ return;
+ }
+ }
+
+ /* now s is neither NaN nor Infinite */
+
if (mpfr_cmp_ui(s,0) == 0) /* Case s = 0 */
{
mpfr_set_ui(z, 1, rnd_mode);