summaryrefslogtreecommitdiff
path: root/log10.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-10-31 12:17:09 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-10-31 12:17:09 +0000
commit1b3112dde0312133db95c18d502a55eee574a960 (patch)
tree2622c36d4983c032fae8360260b94a8ba4729e4b /log10.c
parent526a5ebad30c5be681eee1904991d1300d7f4635 (diff)
downloadmpfr-1b3112dde0312133db95c18d502a55eee574a960.tar.gz
Reformat (GNU coding style).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3915 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'log10.c')
-rw-r--r--log10.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/log10.c b/log10.c
index 8f588701a..7d4bbb3b0 100644
--- a/log10.c
+++ b/log10.c
@@ -80,6 +80,7 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
MPFR_SET_POS (r);
MPFR_RET (0); /* result is exact */
}
+
MPFR_SAVE_EXPO_MARK (expo);
/* General case */
@@ -94,7 +95,7 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
/* compute the precision of intermediary variable */
/* the optimal number of bits : see algorithms.tex */
- Nt = Ny + 4+ MPFR_INT_CEIL_LOG2 (Ny);
+ Nt = Ny + 4 + MPFR_INT_CEIL_LOG2 (Ny);
/* initialise of intermediary variables */
mpfr_init2 (t, Nt);
@@ -102,32 +103,33 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
/* First computation of log10 */
MPFR_ZIV_INIT (loop, Nt);
- for(;;) {
- /* compute log10 */
- mpfr_set_ui (t, 10, GMP_RNDN); /* 10 */
- mpfr_log (t, t, GMP_RNDD); /* log(10) */
- mpfr_log (tt, a, GMP_RNDN); /* log(a) */
- mpfr_div (t, tt, t, GMP_RNDN); /* log(a)/log(10) */
-
- /* estimation of the error */
- err = Nt - 4;
- if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode)))
- break;
-
- /* log10(10^n) is exact:
- FIXME: Can we have 10^n exactly representable as a mpfr_t
- but n can't fit an unsigned long? */
- if (MPFR_IS_POS (t)
- && mpfr_integer_p (t) && mpfr_fits_ulong_p (t, GMP_RNDN)
- && !mpfr_ui_pow_ui (tt, 10, mpfr_get_ui (t, GMP_RNDN), GMP_RNDN)
- && mpfr_cmp (a, tt) == 0)
- break;
-
- /* actualisation of the precision */
- MPFR_ZIV_NEXT (loop, Nt);
- mpfr_set_prec (t, Nt);
- mpfr_set_prec (tt, Nt);
- }
+ for (;;)
+ {
+ /* compute log10 */
+ mpfr_set_ui (t, 10, GMP_RNDN); /* 10 */
+ mpfr_log (t, t, GMP_RNDD); /* log(10) */
+ mpfr_log (tt, a, GMP_RNDN); /* log(a) */
+ mpfr_div (t, tt, t, GMP_RNDN); /* log(a)/log(10) */
+
+ /* estimation of the error */
+ err = Nt - 4;
+ if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode)))
+ break;
+
+ /* log10(10^n) is exact:
+ FIXME: Can we have 10^n exactly representable as a mpfr_t
+ but n can't fit an unsigned long? */
+ if (MPFR_IS_POS (t)
+ && mpfr_integer_p (t) && mpfr_fits_ulong_p (t, GMP_RNDN)
+ && !mpfr_ui_pow_ui (tt, 10, mpfr_get_ui (t, GMP_RNDN), GMP_RNDN)
+ && mpfr_cmp (a, tt) == 0)
+ break;
+
+ /* actualisation of the precision */
+ MPFR_ZIV_NEXT (loop, Nt);
+ mpfr_set_prec (t, Nt);
+ mpfr_set_prec (tt, Nt);
+ }
MPFR_ZIV_FREE (loop);
inexact = mpfr_set (r, t, rnd_mode);