diff options
author | daney <daney@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-11-16 12:34:00 +0000 |
---|---|---|
committer | daney <daney@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-11-16 12:34:00 +0000 |
commit | 373ce1e26e537f0f01225ef7ce837667874679dd (patch) | |
tree | c8ed1b1345bdca9e6c8be8d4454ff84096f0a739 /factorial.c | |
parent | 97dfdf85265024bde0384881e2f2db2b22fc7c09 (diff) | |
download | mpfr-373ce1e26e537f0f01225ef7ce837667874679dd.tar.gz |
remove limits.h
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1537 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'factorial.c')
-rw-r--r-- | factorial.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/factorial.c b/factorial.c index 30a2d462f..9a2e3f8bc 100644 --- a/factorial.c +++ b/factorial.c @@ -19,7 +19,6 @@ along with the MPFR 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> #include "gmp.h" #include "gmp-impl.h" #include "mpfr.h" @@ -48,7 +47,6 @@ mpfr_fac_ui (y, x, rnd_mode) int round, inexact = 0; int boucle = 1; - mp_prec_t Nx; /* Precision of input variable */ mp_prec_t Ny; /* Precision of output variable */ mp_prec_t Nt; /* Precision of Intermediary Calculation variable */ mp_prec_t err; /* Precision of error */ @@ -63,34 +61,33 @@ mpfr_fac_ui (y, x, rnd_mode) else { /* Initialisation of the Precision */ - Nx=sizeof(unsigned long int)*CHAR_BIT; Ny=MPFR_PREC(y); - + Nt=Ny+2*(int)_mpfr_ceil_log2((double)x)+10; /*compute the size of intermediary variable */ - mpfr_init2(t, Nt);/* initialise of intermediary variable */ - - while (boucle) - { - inexact = mpfr_set_ui (t, 1, GMP_RNDZ); - - for(i=2;i<=x;i++) /* compute factorial */ - { - round = mpfr_mul_ui (t, t, i, GMP_RNDZ); - /* assume the first inexact product gives the sign - of difference: is that always correct? */ - if (inexact == 0) - inexact = round; - } + mpfr_init2(t, Nt);/* initialise of intermediary variable */ + + while (boucle) + { + inexact = mpfr_set_ui (t, 1, GMP_RNDZ); + + for(i=2;i<=x;i++) /* compute factorial */ + { + round = mpfr_mul_ui (t, t, i, GMP_RNDZ); + /* assume the first inexact product gives the sign + of difference: is that always correct? */ + if (inexact == 0) + inexact = round; + } - err = Nt - 1 - (int) _mpfr_ceil_log2 ((double) Nt); - - round = !inexact || mpfr_can_round (t,err,GMP_RNDZ,rnd_mode,Ny); + err = Nt - 1 - (int) _mpfr_ceil_log2 ((double) Nt); - if (round) - { - round = mpfr_set (y, t, rnd_mode); + round = !inexact || mpfr_can_round (t,err,GMP_RNDZ,rnd_mode,Ny); + + if (round) + { + round = mpfr_set (y, t, rnd_mode); if (inexact == 0) inexact = round; boucle=0; |