diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2023-08-26 04:23:11 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2023-08-26 04:23:11 +0000 |
commit | b0cdc7933e2c0a55dc6d8f395fff072b8b1d1cd1 (patch) | |
tree | f8bd9111112dbf49c662452f66bd9a995e3c48f0 /Build/source/libs/mpfr/mpfr-src/src | |
parent | c492ce6804085c9686633f8da2be27fd72c9f0e2 (diff) |
mpfr 4.2.1
git-svn-id: svn://tug.org/texlive/trunk@68066 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src')
104 files changed, 534 insertions, 355 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/Makefile.am b/Build/source/libs/mpfr/mpfr-src/src/Makefile.am index ce8efcfb85f..c2196f8104e 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/Makefile.am +++ b/Build/source/libs/mpfr/mpfr-src/src/Makefile.am @@ -103,7 +103,7 @@ libmpfr_la_LIBADD = @LIBOBJS@ # 4.0.x 6:x:0 # 4.1.x 7:x:1 # 4.2.x 8:x:2 -libmpfr_la_LDFLAGS = $(MPFR_LDFLAGS) $(LIBMPFR_LDFLAGS) -version-info 8:0:2 +libmpfr_la_LDFLAGS = $(MPFR_LDFLAGS) $(LIBMPFR_LDFLAGS) -version-info 8:1:2 GET_PATCHES_SH = $(top_srcdir)/tools/get_patches.sh PATCHES = $(top_srcdir)/PATCHES diff --git a/Build/source/libs/mpfr/mpfr-src/src/acos.c b/Build/source/libs/mpfr/mpfr-src/src/acos.c index ce43a784792..1661283c257 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/acos.c +++ b/Build/source/libs/mpfr/mpfr-src/src/acos.c @@ -34,8 +34,8 @@ mpfr_acos (mpfr_ptr acos, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("acos[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), + ("acos[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(acos), mpfr_log_prec, acos, inexact)); /* Singular cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/acosh.c b/Build/source/libs/mpfr/mpfr-src/src/acosh.c index 21ee49950d6..648bb5b72b3 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/acosh.c +++ b/Build/source/libs/mpfr/mpfr-src/src/acosh.c @@ -34,8 +34,8 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) int comp; MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* Deal with special cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/acosu.c b/Build/source/libs/mpfr/mpfr-src/src/acosu.c index 73b67f5ecdf..3f90c247f4e 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/acosu.c +++ b/Build/source/libs/mpfr/mpfr-src/src/acosu.c @@ -36,9 +36,9 @@ mpfr_acosu (mpfr_ptr y, mpfr_srcptr x, unsigned long u, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, + (("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* Singular cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/add.c b/Build/source/libs/mpfr/mpfr-src/src/add.c index bd5866ef52f..d3947b7d77c 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/add.c +++ b/Build/source/libs/mpfr/mpfr-src/src/add.c @@ -26,10 +26,10 @@ MPFR_HOT_FUNCTION_ATTR int mpfr_add (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) { MPFR_LOG_FUNC - (("b[%Pu]=%.*Rg c[%Pu]=%.*Rg rnd=%d", + (("b[%Pd]=%.*Rg c[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (b), mpfr_log_prec, b, mpfr_get_prec (c), mpfr_log_prec, c, rnd_mode), - ("a[%Pu]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); + ("a[%Pd]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); if (MPFR_ARE_SINGULAR_OR_UBF (b, c)) { diff --git a/Build/source/libs/mpfr/mpfr-src/src/add_d.c b/Build/source/libs/mpfr/mpfr-src/src/add_d.c index 7adeb5c5350..e245e0eb34e 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/add_d.c +++ b/Build/source/libs/mpfr/mpfr-src/src/add_d.c @@ -32,9 +32,9 @@ mpfr_add_d (mpfr_ptr a, mpfr_srcptr b, double c, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("b[%Pu]=%.*Rg c=%.20g rnd=%d", + (("b[%Pd]=%.*Rg c=%.20g rnd=%d", mpfr_get_prec(b), mpfr_log_prec, b, c, rnd_mode), - ("a[%Pu]=%.*Rg inexact=%d", + ("a[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (a), mpfr_log_prec, a, inexact)); MPFR_SAVE_EXPO_MARK (expo); diff --git a/Build/source/libs/mpfr/mpfr-src/src/add_ui.c b/Build/source/libs/mpfr/mpfr-src/src/add_ui.c index 6fbeed6192b..2060673f73e 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/add_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/add_ui.c @@ -27,9 +27,9 @@ MPFR_HOT_FUNCTION_ATTR int mpfr_add_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mpfr_rnd_t rnd_mode) { MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%lu rnd=%d", + (("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); + ("y[%Pd]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); /* (unsigned long) 0 is assumed to be a real 0 (unsigned) */ if (MPFR_UNLIKELY (u == 0)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/agm.c b/Build/source/libs/mpfr/mpfr-src/src/agm.c index 3239ccca693..14fbe65891d 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/agm.c +++ b/Build/source/libs/mpfr/mpfr-src/src/agm.c @@ -39,10 +39,10 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("op2[%Pu]=%.*Rg op1[%Pu]=%.*Rg rnd=%d", + (("op2[%Pd]=%.*Rg op1[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (op2), mpfr_log_prec, op2, mpfr_get_prec (op1), mpfr_log_prec, op1, rnd_mode), - ("r[%Pu]=%.*Rg inexact=%d", + ("r[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, inexact)); /* Deal with special values */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/ai.c b/Build/source/libs/mpfr/mpfr-src/src/ai.c index aa8e8d91ffa..4d5221d00cb 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/ai.c +++ b/Build/source/libs/mpfr/mpfr-src/src/ai.c @@ -70,8 +70,8 @@ mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) /* Logging */ MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), - ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y) ); + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), + ("y[%Pd]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y) ); /* Save current exponents range */ MPFR_SAVE_EXPO_MARK (expo); @@ -198,7 +198,7 @@ mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) /* ZIV loop */ for (;;) { - MPFR_LOG_MSG (("Working precision: %Pu\n", wprec)); + MPFR_LOG_MSG (("Working precision: %Pd\n", wprec)); mpfr_set_prec (ti, wprec); mpfr_set_prec (tip1, wprec); mpfr_set_prec (x3, wprec); @@ -257,8 +257,8 @@ mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) /* err is the number of bits lost due to the evaluation error */ /* wprec-(prec+1): number of bits lost due to the approximation error */ - MPFR_LOG_MSG (("Roundoff error: %Pu\n", err)); - MPFR_LOG_MSG (("Approxim error: %Pu\n", wprec-prec-1)); + MPFR_LOG_MSG (("Roundoff error: %Pd\n", err)); + MPFR_LOG_MSG (("Approxim error: %Pd\n", wprec-prec-1)); if (wprec < err + 1) correct_bits = 0; @@ -342,8 +342,8 @@ mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) /* Logging */ MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), - ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), + ("y[%Pd]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); /* Save current exponents range */ MPFR_SAVE_EXPO_MARK (expo); @@ -431,7 +431,7 @@ mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) /* ZIV loop */ for (;;) { - MPFR_LOG_MSG (("working precision: %Pu\n", wprec)); + MPFR_LOG_MSG (("working precision: %Pd\n", wprec)); for (j=0; j<=L; j++) mpfr_set_prec (z[j], wprec); @@ -548,8 +548,8 @@ mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) /* err is the number of bits lost due to the evaluation error */ /* wprec-(prec+1): number of bits lost due to the approximation error */ - MPFR_LOG_MSG (("Roundoff error: %Pu\n", err)); - MPFR_LOG_MSG (("Approxim error: %Pu\n", wprec - prec - 1)); + MPFR_LOG_MSG (("Roundoff error: %Pd\n", err)); + MPFR_LOG_MSG (("Approxim error: %Pd\n", wprec - prec - 1)); if (wprec < err+1) correctBits = 0; diff --git a/Build/source/libs/mpfr/mpfr-src/src/asin.c b/Build/source/libs/mpfr/mpfr-src/src/asin.c index 29eae21f775..185625139b8 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/asin.c +++ b/Build/source/libs/mpfr/mpfr-src/src/asin.c @@ -33,8 +33,8 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("asin[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (asin), mpfr_log_prec, asin, + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("asin[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (asin), mpfr_log_prec, asin, inexact)); /* Special cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/asinh.c b/Build/source/libs/mpfr/mpfr-src/src/asinh.c index 831f3fa7904..4c9fd30d012 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/asinh.c +++ b/Build/source/libs/mpfr/mpfr-src/src/asinh.c @@ -38,8 +38,8 @@ mpfr_asinh (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/asinu.c b/Build/source/libs/mpfr/mpfr-src/src/asinu.c index 5c4e968de62..09cb66b1e90 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/asinu.c +++ b/Build/source/libs/mpfr/mpfr-src/src/asinu.c @@ -35,9 +35,9 @@ mpfr_asinu (mpfr_ptr y, mpfr_srcptr x, unsigned long u, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, + (("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* Singular cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/atan.c b/Build/source/libs/mpfr/mpfr-src/src/atan.c index 4220bcbafb8..29b75cdb57c 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/atan.c +++ b/Build/source/libs/mpfr/mpfr-src/src/atan.c @@ -298,8 +298,8 @@ mpfr_atan (mpfr_ptr atan, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("atan[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("atan[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (atan), mpfr_log_prec, atan, inexact)); /* Singular cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/atan2.c b/Build/source/libs/mpfr/mpfr-src/src/atan2.c index 469c84333ff..a0bc8c241aa 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/atan2.c +++ b/Build/source/libs/mpfr/mpfr-src/src/atan2.c @@ -55,10 +55,10 @@ mpfr_atan2 (mpfr_ptr dest, mpfr_srcptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("y[%Pu]=%.*Rg x[%Pu]=%.*Rg rnd=%d", + (("y[%Pd]=%.*Rg x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (y), mpfr_log_prec, y, mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("atan[%Pu]=%.*Rg inexact=%d", + ("atan[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (dest), mpfr_log_prec, dest, inexact)); /* Special cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/atan2u.c b/Build/source/libs/mpfr/mpfr-src/src/atan2u.c index d5ec829ccb9..d6147428c6d 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/atan2u.c +++ b/Build/source/libs/mpfr/mpfr-src/src/atan2u.c @@ -171,11 +171,11 @@ mpfr_atan2u (mpfr_ptr z, mpfr_srcptr y, mpfr_srcptr x, unsigned long u, MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("y[%Pu]=%.*Rg x[%Pu]=%.*Rg u=%lu rnd=%d", + (("y[%Pd]=%.*Rg x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(y), mpfr_log_prec, y, mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("z[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (z), mpfr_log_prec, z, + ("z[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (z), mpfr_log_prec, z, inex)); /* Special cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/atanh.c b/Build/source/libs/mpfr/mpfr-src/src/atanh.c index 20cac085b26..b832049cfea 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/atanh.c +++ b/Build/source/libs/mpfr/mpfr-src/src/atanh.c @@ -110,8 +110,8 @@ mpfr_atanh (mpfr_ptr y, mpfr_srcptr xt, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* Special cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/atanu.c b/Build/source/libs/mpfr/mpfr-src/src/atanu.c index 780213c9c5a..d44c573e107 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/atanu.c +++ b/Build/source/libs/mpfr/mpfr-src/src/atanu.c @@ -36,9 +36,9 @@ mpfr_atanu (mpfr_ptr y, mpfr_srcptr x, unsigned long u, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, + (("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex)); /* Singular cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/cbrt.c b/Build/source/libs/mpfr/mpfr-src/src/cbrt.c index 11c8e8f48bd..9de4539a0ea 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/cbrt.c +++ b/Build/source/libs/mpfr/mpfr-src/src/cbrt.c @@ -55,8 +55,8 @@ mpfr_cbrt (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* special values */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/compound.c b/Build/source/libs/mpfr/mpfr-src/src/compound.c index 16f3b88d2f3..61fa04f114f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/compound.c +++ b/Build/source/libs/mpfr/mpfr-src/src/compound.c @@ -55,16 +55,16 @@ int mpfr_compound_si (mpfr_ptr y, mpfr_srcptr x, long n, mpfr_rnd_t rnd_mode) { int inexact, compared, k, nloop; - mpfr_t t; - mpfr_exp_t e; - mpfr_prec_t prec; + mpfr_t t, u; + mpfr_prec_t py, prec, extra; + mpfr_rnd_t rnd1; MPFR_ZIV_DECL (loop); MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg n=%ld rnd=%d", + (("x[%Pd]=%.*Rg n=%ld rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, n, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* Special cases */ if (MPFR_IS_SINGULAR (x)) @@ -136,64 +136,181 @@ mpfr_compound_si (mpfr_ptr y, mpfr_srcptr x, long n, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_MARK (expo); - prec = MPFR_PREC(y); - prec += MPFR_INT_CEIL_LOG2 (prec) + 6; + py = MPFR_GET_PREC (y); + prec = py + MPFR_INT_CEIL_LOG2 (py) + 6; mpfr_init2 (t, prec); + mpfr_init2 (u, prec); k = MPFR_INT_CEIL_LOG2(SAFE_ABS (unsigned long, n)); /* thus |n| <= 2^k */ + /* We compute u=log2p1(x) with prec+extra bits, since we lose some bits + in 2^u. */ + extra = 0; + rnd1 = VSIGN (n) == MPFR_SIGN (x) ? MPFR_RNDD : MPFR_RNDU; + MPFR_ZIV_INIT (loop, prec); for (nloop = 0; ; nloop++) { - /* we compute (1+x)^n as 2^(n*log2p1(x)) */ - inexact = mpfr_log2p1 (t, x, MPFR_RNDN) != 0; - e = MPFR_GET_EXP(t); - /* |t - log2(1+x)| <= 1/2*ulp(t) = 2^(e-prec-1) */ - inexact |= mpfr_mul_si (t, t, n, MPFR_RNDN) != 0; - /* |t - n*log2(1+x)| <= 2^(e2-prec-1) + |n|*2^(e-prec-1) - <= 2^(e2-prec-1) + 2^(e+k-prec-1) <= 2^(e+k-prec) - where |n| <= 2^k, and e2 is the new exponent of t. */ - MPFR_ASSERTD(MPFR_GET_EXP(t) <= e + k); - e += k; - /* |t - n*log2(1+x)| <= 2^(e-prec) */ - /* detect overflow */ - if (nloop == 0 && mpfr_cmp_si (t, __gmpfr_emax) >= 0) + unsigned int inex; + mpfr_exp_t e, e2, ex; + mpfr_prec_t precu = MPFR_ADD_PREC (prec, extra); + mpfr_prec_t new_extra; + mpfr_rnd_t rnd2; + + /* We compute (1+x)^n as 2^(n*log2p1(x)), + and we round toward 1, thus we round n*log2p1(x) toward 0, + thus for x*n > 0 we round log2p1(x) toward -Inf, and for x*n < 0 + we round log2p1(x) toward +Inf. */ + inex = mpfr_log2p1 (u, x, rnd1) != 0; + e = MPFR_GET_EXP (u); + /* |u - log2(1+x)| <= ulp(t) = 2^(e-precu) */ + inex |= mpfr_mul_si (u, u, n, MPFR_RNDZ) != 0; + e2 = MPFR_GET_EXP (u); + /* |u - n*log2(1+x)| <= 2^(e2-precu) + |n|*2^(e-precu) + <= 2^(e2-precu) + 2^(e+k-precu) <= 2^(e+k+1-precu) + where |n| <= 2^k, and e2 is the new exponent of u. */ + MPFR_ASSERTD (e2 <= e + k); + e += k + 1; + MPFR_ASSERTN (e2 <= MPFR_PREC_MAX); + new_extra = e2 > 0 ? e2 : 0; + /* |u - n*log2(1+x)| <= 2^(e-precu) */ + /* detect overflow: since we rounded n*log2p1(x) toward 0, + if n*log2p1(x) >= __gmpfr_emax, we are sure there is overflow. */ + if (mpfr_cmp_si (u, __gmpfr_emax) >= 0) { MPFR_ZIV_FREE (loop); mpfr_clear (t); + mpfr_clear (u); MPFR_SAVE_EXPO_FREE (expo); return mpfr_overflow (y, rnd_mode, 1); } - /* detect underflow */ - if (nloop == 0 && mpfr_cmp_si (t, __gmpfr_emin - 1) <= 0) + /* detect underflow: similarly, since we rounded n*log2p1(x) toward 0, + if n*log2p1(x) < __gmpfr_emin-1, we are sure there is underflow. */ + if (mpfr_cmp_si (u, __gmpfr_emin - 1) < 0) { MPFR_ZIV_FREE (loop); mpfr_clear (t); + mpfr_clear (u); MPFR_SAVE_EXPO_FREE (expo); return mpfr_underflow (y, - (rnd_mode == MPFR_RNDN) ? MPFR_RNDZ : rnd_mode, 1); + rnd_mode == MPFR_RNDN ? MPFR_RNDZ : rnd_mode, 1); } /* Detect cases where result is 1 or 1+ulp(1) or 1-1/2*ulp(1): - |2^t - 1| = |exp(t*log(2)) - 1| <= |t|*log(2) < |t| */ - if (nloop == 0 && MPFR_GET_EXP(t) < - (mpfr_exp_t) MPFR_PREC(y)) + |2^u - 1| = |exp(u*log(2)) - 1| <= |u|*log(2) < |u| */ + if (nloop == 0 && MPFR_GET_EXP(u) < - py) { - /* since ulp(1) = 2^(1-PREC(y)), we have |t| < 1/4*ulp(1) */ + /* since ulp(1) = 2^(1-py), we have |u| < 1/4*ulp(1) */ /* mpfr_compound_near_one must be called in the extended exponent range, so that 1 is representable. */ - inexact = mpfr_compound_near_one (y, MPFR_SIGN (t), rnd_mode); + inexact = mpfr_compound_near_one (y, MPFR_SIGN (u), rnd_mode); goto end; } - inexact |= mpfr_exp2 (t, t, MPFR_RNDA) != 0; - /* |t - (1+x)^n| <= ulp(t) + |t|*log(2)*2^(e-prec) - < 2^(EXP(t)-prec) + 2^(EXP(t)+e-prec) */ - e = (e >= 0) ? e + 1 : 1; + /* round 2^u toward 1 */ + rnd2 = MPFR_IS_POS (u) ? MPFR_RNDD : MPFR_RNDU; + inex |= mpfr_exp2 (t, u, rnd2) != 0; + /* we had |u - n*log2(1+x)| < 2^(e-precu) + thus u = n*log2(1+x) + delta with |delta| < 2^(e-precu) + then 2^u = (1+x)^n * 2^delta with |delta| < 2^(e-precu). + For |delta| < 0.5, |2^delta - 1| <= |delta| thus + |t - (1+x)^n| <= ulp(t) + |t|*2^(e-precu) + < 2^(EXP(t)-prec) + 2^(EXP(t)+e-precu) */ + e = (precu - prec >= e) ? 1 : e + 1 - (precu - prec); /* now |t - (1+x)^n| < 2^(EXP(t)+e-prec) */ - if (MPFR_LIKELY (inexact == 0 || - MPFR_CAN_ROUND (t, prec - e, MPFR_PREC(y), rnd_mode))) + if (MPFR_LIKELY (!inex || MPFR_CAN_ROUND (t, prec - e, py, rnd_mode))) break; + /* If t fits in the target precision (or with 1 more bit), then we can + round, assuming the working precision is large enough, but the above + MPFR_CAN_ROUND() will fail because we cannot determine the ternary + value. However since we rounded t toward 1, we can determine it. + Since the error in the approximation t is at most 2^e ulp(t), + this error should be less than 1/2 ulp(y), thus we should have + prec - py >= e + 1. */ + if (mpfr_min_prec (t) <= py + 1 && prec - py >= e + 1) + { + /* we add/subtract one ulp to get the correct rounding */ + if (rnd2 == MPFR_RNDD) /* t was rounded downwards */ + mpfr_nextabove (t); + else + mpfr_nextbelow (t); + break; + } + + /* Detect particular cases where Ziv's strategy may take too much + memory and be too long, i.e. when x^n fits in the target precision + (+ 1 additional bit for rounding to nearest) and the exact result + (1+x)^n is very close to x^n. + Necessarily, x is a large even integer and n > 0 (thus n > 1). + Since this does not depend on the working precision, we only + check this at the first iteration (nloop == 0). + Hence the first "if" below and the kx < ex test of the second "if" + (x is an even integer iff its least bit 1 has exponent >= 1). + The second test of the second "if" corresponds to another simple + condition that implies that x^n fits in the target precision. + Here are the details: + Let k be the minimum length of the significand of x, and x' the odd + (integer) significand of x. This means that 2^(k-1) <= x' < 2^k. + Thus 2^(n*(k-1)) <= (x')^n < 2^(k*n), and x^n has between n*(k-1)+1 + and k*n bits. So x^n can fit into p bits only if p >= n*(k-1)+1, + i.e. n*(k-1) <= p-1. + Note that x >= 2^k, so that x^n >= 2^(k*n). Since raw overflow + has already been detected, k*n cannot overflow if computed with + the mpfr_exp_t type. Hence the second test of the second "if", + which cannot overflow. */ + MPFR_ASSERTD (n < 0 || n > 1); + if (nloop == 0 && n > 1 && (ex = MPFR_GET_EXP (x)) >= 17) + { + mpfr_prec_t kx = mpfr_min_prec (x); + mpfr_prec_t p = py + (rnd_mode == MPFR_RNDN); + + MPFR_LOG_MSG (("Check if x^n fits... n=%ld kx=%Pd p=%Pd\n", + n, kx, p)); + if (kx < ex && n * (mpfr_exp_t) (kx - 1) <= p - 1) + { + mpfr_t v; + + /* Check whether x^n really fits into p bits. */ + mpfr_init2 (v, p); + inexact = mpfr_pow_ui (v, x, n, MPFR_RNDZ); + if (inexact == 0) + { + MPFR_LOG_MSG (("x^n fits into p bits\n", 0)); + /* (x+1)^n = x^n * (1 + 1/x)^n + For directed rounding, we can round when (1 + 1/x)^n + < 1 + 2^-p, and then the result is x^n, + except for rounding up. Indeed, if (1 + 1/x)^n < 1 + 2^-p, + 1 <= (x+1)^n < x^n * (1 + 2^-p) = x^n + x^n/2^p + < x^n + ulp(x^n). + For rounding to nearest, we can round when (1 + 1/x)^n + < 1 + 2^-p, and then the result is x^n when x^n fits + into p-1 bits, and nextabove(x^n) otherwise. */ + mpfr_ui_div (t, 1, x, MPFR_RNDU); + mpfr_add_ui (t, t, 1, MPFR_RNDU); + mpfr_pow_ui (t, t, n, MPFR_RNDU); + mpfr_sub_ui (t, t, 1, MPFR_RNDU); + /* t cannot be zero */ + if (MPFR_GET_EXP(t) < - py) + { + mpfr_set (y, v, MPFR_RNDZ); + if ((rnd_mode == MPFR_RNDN && mpfr_min_prec (v) == p) + || rnd_mode == MPFR_RNDU || rnd_mode == MPFR_RNDA) + { + /* round up */ + mpfr_nextabove (y); + inexact = 1; + } + else + inexact = -1; + mpfr_clear (v); + goto end; + } + } + mpfr_clear (v); + } + } + /* Exact cases like compound(0.5,2) = 9/4 must be detected, since except for 1+x power of 2, the log2p1 above will be inexact, so that in the Ziv test, inexact != 0 and MPFR_CAN_ROUND will @@ -211,6 +328,8 @@ mpfr_compound_si (mpfr_ptr y, mpfr_srcptr x, long n, mpfr_rnd_t rnd_mode) MPFR_ZIV_NEXT (loop, prec); mpfr_set_prec (t, prec); + extra = new_extra; + mpfr_set_prec (u, MPFR_ADD_PREC (prec, extra)); } inexact = mpfr_set (y, t, rnd_mode); @@ -218,6 +337,7 @@ mpfr_compound_si (mpfr_ptr y, mpfr_srcptr x, long n, mpfr_rnd_t rnd_mode) end: MPFR_ZIV_FREE (loop); mpfr_clear (t); + mpfr_clear (u); MPFR_SAVE_EXPO_FREE (expo); return mpfr_check_range (y, inexact, rnd_mode); diff --git a/Build/source/libs/mpfr/mpfr-src/src/const_catalan.c b/Build/source/libs/mpfr/mpfr-src/src/const_catalan.c index 2c748c933c8..c8738660366 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/const_catalan.c +++ b/Build/source/libs/mpfr/mpfr-src/src/const_catalan.c @@ -92,7 +92,7 @@ mpfr_const_catalan_internal (mpfr_ptr g, mpfr_rnd_t rnd_mode) MPFR_GROUP_DECL (group); MPFR_LOG_FUNC (("rnd_mode=%d", rnd_mode), - ("g[%Pu]=%.*Rg inex=%d", mpfr_get_prec (g), mpfr_log_prec, g, inex)); + ("g[%Pd]=%.*Rg inex=%d", mpfr_get_prec (g), mpfr_log_prec, g, inex)); /* Here are the WC (max prec = 100.000.000) Once we have found a chain of 11, we only look for bigger chain. diff --git a/Build/source/libs/mpfr/mpfr-src/src/const_log2.c b/Build/source/libs/mpfr/mpfr-src/src/const_log2.c index 7e29e40faff..64d7a43c3cd 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/const_log2.c +++ b/Build/source/libs/mpfr/mpfr-src/src/const_log2.c @@ -121,7 +121,7 @@ mpfr_const_log2_internal (mpfr_ptr x, mpfr_rnd_t rnd_mode) MPFR_LOG_FUNC ( ("rnd_mode=%d", rnd_mode), - ("x[%Pu]=%.*Rg inex=%d", mpfr_get_prec(x), mpfr_log_prec, x, inexact)); + ("x[%Pd]=%.*Rg inex=%d", mpfr_get_prec(x), mpfr_log_prec, x, inexact)); w = n + MPFR_INT_CEIL_LOG2 (n) + 3; diff --git a/Build/source/libs/mpfr/mpfr-src/src/const_pi.c b/Build/source/libs/mpfr/mpfr-src/src/const_pi.c index e72e2e11e42..a1627a45a02 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/const_pi.c +++ b/Build/source/libs/mpfr/mpfr-src/src/const_pi.c @@ -55,7 +55,7 @@ mpfr_const_pi_internal (mpfr_ptr x, mpfr_rnd_t rnd_mode) MPFR_LOG_FUNC (("rnd_mode=%d", rnd_mode), - ("x[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(x), mpfr_log_prec, x, inex)); + ("x[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(x), mpfr_log_prec, x, inex)); px = MPFR_PREC (x); diff --git a/Build/source/libs/mpfr/mpfr-src/src/cos.c b/Build/source/libs/mpfr/mpfr-src/src/cos.c index b6403687330..308242b72b9 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/cos.c +++ b/Build/source/libs/mpfr/mpfr-src/src/cos.c @@ -141,8 +141,8 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_GROUP_DECL (group); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/cosh.c b/Build/source/libs/mpfr/mpfr-src/src/cosh.c index 9341b170ba7..c5dbc33a4fe 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/cosh.c +++ b/Build/source/libs/mpfr/mpfr-src/src/cosh.c @@ -34,8 +34,8 @@ mpfr_cosh (mpfr_ptr y, mpfr_srcptr xt, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(xt))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/cosu.c b/Build/source/libs/mpfr/mpfr-src/src/cosu.c index 97ecfaa7570..b318e7680d3 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/cosu.c +++ b/Build/source/libs/mpfr/mpfr-src/src/cosu.c @@ -37,9 +37,9 @@ mpfr_cosu (mpfr_ptr y, mpfr_srcptr x, unsigned long u, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg u=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, u, + ("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (u == 0 || MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/d_div.c b/Build/source/libs/mpfr/mpfr-src/src/d_div.c index 9a0600ccb39..9afa7e2dd26 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/d_div.c +++ b/Build/source/libs/mpfr/mpfr-src/src/d_div.c @@ -32,8 +32,8 @@ mpfr_d_div (mpfr_ptr a, double b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("b=%.20g c[%Pu]=%.*Rg rnd=%d", b, mpfr_get_prec (c), mpfr_log_prec, c, rnd_mode), - ("a[%Pu]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); + ("b=%.20g c[%Pd]=%.*Rg rnd=%d", b, mpfr_get_prec (c), mpfr_log_prec, c, rnd_mode), + ("a[%Pd]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); MPFR_SAVE_EXPO_MARK (expo); diff --git a/Build/source/libs/mpfr/mpfr-src/src/d_sub.c b/Build/source/libs/mpfr/mpfr-src/src/d_sub.c index 4496ab907cd..41e3309378f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/d_sub.c +++ b/Build/source/libs/mpfr/mpfr-src/src/d_sub.c @@ -32,8 +32,8 @@ mpfr_d_sub (mpfr_ptr a, double b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("b=%.20g c[%Pu]=%.*Rg rnd=%d", b, mpfr_get_prec (c), mpfr_log_prec, c, rnd_mode), - ("a[%Pu]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); + ("b=%.20g c[%Pd]=%.*Rg rnd=%d", b, mpfr_get_prec (c), mpfr_log_prec, c, rnd_mode), + ("a[%Pd]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); MPFR_SAVE_EXPO_MARK (expo); diff --git a/Build/source/libs/mpfr/mpfr-src/src/digamma.c b/Build/source/libs/mpfr/mpfr-src/src/digamma.c index 6cb7ec8d864..92c604be41e 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/digamma.c +++ b/Build/source/libs/mpfr/mpfr-src/src/digamma.c @@ -122,8 +122,8 @@ mpfr_digamma_reflection (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inex)); + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inex)); /* we want that 1-x is exact with precision q: if 0 < x < 1/2, then q = PREC(x)-EXP(x) is ok, otherwise if -1 <= x < 0, q = PREC(x)-EXP(x) @@ -214,8 +214,8 @@ mpfr_digamma_positive (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inex)); + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inex)); /* For very large x, use |digamma(x) - log(x)| < 1/x < 2^(1-EXP(x)). However, for a fixed value of GUARD, MPFR_CAN_ROUND() might fail @@ -259,7 +259,7 @@ mpfr_digamma_positive (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) q = MPFR_PREC(x) + 1; /* FIXME: q can be much too large, e.g. equal to the maximum exponent! */ - MPFR_LOG_MSG (("q=%Pu\n", q)); + MPFR_LOG_MSG (("q=%Pd\n", q)); mpfr_init2 (x_plus_j, q); @@ -338,8 +338,8 @@ mpfr_digamma (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inex)); + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inex)); if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x))) { diff --git a/Build/source/libs/mpfr/mpfr-src/src/div.c b/Build/source/libs/mpfr/mpfr-src/src/div.c index 28426c483e9..3f90fac3245 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/div.c +++ b/Build/source/libs/mpfr/mpfr-src/src/div.c @@ -770,10 +770,10 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode) MPFR_TMP_DECL(marker); MPFR_LOG_FUNC ( - ("u[%Pu]=%.*Rg v[%Pu]=%.*Rg rnd=%d", + ("u[%Pd]=%.*Rg v[%Pd]=%.*Rg rnd=%d", mpfr_get_prec(u), mpfr_log_prec, u, mpfr_get_prec (v),mpfr_log_prec, v, rnd_mode), - ("q[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(q), mpfr_log_prec, q, inex)); + ("q[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(q), mpfr_log_prec, q, inex)); /************************************************************************** * * diff --git a/Build/source/libs/mpfr/mpfr-src/src/div_2si.c b/Build/source/libs/mpfr/mpfr-src/src/div_2si.c index ae584a409a5..a31e066ae3c 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/div_2si.c +++ b/Build/source/libs/mpfr/mpfr-src/src/div_2si.c @@ -28,9 +28,9 @@ mpfr_div_2si (mpfr_ptr y, mpfr_srcptr x, long int n, mpfr_rnd_t rnd_mode) int inexact; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg n=%ld rnd=%d", + (("x[%Pd]=%.*Rg n=%ld rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, n, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/div_2ui.c b/Build/source/libs/mpfr/mpfr-src/src/div_2ui.c index 7dac999b09f..112995048f9 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/div_2ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/div_2ui.c @@ -28,9 +28,9 @@ mpfr_div_2ui (mpfr_ptr y, mpfr_srcptr x, unsigned long n, mpfr_rnd_t rnd_mode) int inexact; MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg n=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, n, + ("x[%Pd]=%.*Rg n=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, n, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (n == 0 || MPFR_IS_SINGULAR (x))) return mpfr_set (y, x, rnd_mode); diff --git a/Build/source/libs/mpfr/mpfr-src/src/div_d.c b/Build/source/libs/mpfr/mpfr-src/src/div_d.c index f5fdf9b6789..de84a88fbf8 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/div_d.c +++ b/Build/source/libs/mpfr/mpfr-src/src/div_d.c @@ -32,9 +32,9 @@ mpfr_div_d (mpfr_ptr a, mpfr_srcptr b, double c, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("b[%Pu]=%.*Rg c%.20g rnd=%d", mpfr_get_prec (b), mpfr_log_prec, b, c, + ("b[%Pd]=%.*Rg c%.20g rnd=%d", mpfr_get_prec (b), mpfr_log_prec, b, c, rnd_mode), - ("a[%Pu]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); + ("a[%Pd]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); MPFR_SAVE_EXPO_MARK (expo); diff --git a/Build/source/libs/mpfr/mpfr-src/src/div_ui.c b/Build/source/libs/mpfr/mpfr-src/src/div_ui.c index 4e051ea1fc6..85303ac84b7 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/div_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/div_ui.c @@ -46,9 +46,9 @@ mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, MPFR_TMP_DECL(marker); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%lu rnd=%d", + (("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/eint.c b/Build/source/libs/mpfr/mpfr-src/src/eint.c index f9eb54f29e7..2c35c498eb7 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/eint.c +++ b/Build/source/libs/mpfr/mpfr-src/src/eint.c @@ -47,8 +47,8 @@ mpfr_eint_aux (mpfr_ptr y, mpfr_srcptr x) MPFR_GROUP_DECL (group); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg", mpfr_get_prec (x), mpfr_log_prec, x), - ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); + ("x[%Pd]=%.*Rg", mpfr_get_prec (x), mpfr_log_prec, x), + ("y[%Pd]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); /* for |x| <= 1, we have S := sum(x^k/k/k!, k=1..infinity) = x + R(x) where |R(x)| <= (x/2)^2/(1-|x|/2) <= 2*(x/2)^2 @@ -182,7 +182,7 @@ mpfr_eint_asympt (mpfr_ptr y, mpfr_srcptr x) mpfr_exp_t err_exp; MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg", mpfr_get_prec (x), mpfr_log_prec, x), + ("x[%Pd]=%.*Rg", mpfr_get_prec (x), mpfr_log_prec, x), ("err_exp=%" MPFR_EXP_FSPEC "d", (mpfr_eexp_t) err_exp)); mpfr_init2 (t, p); @@ -232,8 +232,8 @@ mpfr_eint (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex)); + ("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) { diff --git a/Build/source/libs/mpfr/mpfr-src/src/erf.c b/Build/source/libs/mpfr/mpfr-src/src/erf.c index b0d820ed5af..c62cf1dbf3f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/erf.c +++ b/Build/source/libs/mpfr/mpfr-src/src/erf.c @@ -34,8 +34,8 @@ mpfr_erf (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex)); + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) { diff --git a/Build/source/libs/mpfr/mpfr-src/src/erfc.c b/Build/source/libs/mpfr/mpfr-src/src/erfc.c index b2db6a9e12a..1dbc2305c93 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/erfc.c +++ b/Build/source/libs/mpfr/mpfr-src/src/erfc.c @@ -132,8 +132,8 @@ mpfr_erfc (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex)); + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) { diff --git a/Build/source/libs/mpfr/mpfr-src/src/exceptions.c b/Build/source/libs/mpfr/mpfr-src/src/exceptions.c index 800d9936a08..82b224e3c5d 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/exceptions.c +++ b/Build/source/libs/mpfr/mpfr-src/src/exceptions.c @@ -384,7 +384,7 @@ mpfr_underflow (mpfr_ptr x, mpfr_rnd_t rnd_mode, int sign) MPFR_LOG_FUNC (("rnd=%d sign=%d", rnd_mode, sign), - ("x[%Pu]=%.*Rg", mpfr_get_prec (x), mpfr_log_prec, x)); + ("x[%Pd]=%.*Rg", mpfr_get_prec (x), mpfr_log_prec, x)); MPFR_ASSERT_SIGN (sign); @@ -412,7 +412,7 @@ mpfr_overflow (mpfr_ptr x, mpfr_rnd_t rnd_mode, int sign) MPFR_LOG_FUNC (("rnd=%d sign=%d", rnd_mode, sign), - ("x[%Pu]=%.*Rg", mpfr_get_prec (x), mpfr_log_prec, x)); + ("x[%Pd]=%.*Rg", mpfr_get_prec (x), mpfr_log_prec, x)); MPFR_ASSERT_SIGN (sign); diff --git a/Build/source/libs/mpfr/mpfr-src/src/exp.c b/Build/source/libs/mpfr/mpfr-src/src/exp.c index de57dcddd72..ff5eea86596 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/exp.c +++ b/Build/source/libs/mpfr/mpfr-src/src/exp.c @@ -41,8 +41,8 @@ mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(x) )) diff --git a/Build/source/libs/mpfr/mpfr-src/src/exp10m1.c b/Build/source/libs/mpfr/mpfr-src/src/exp10m1.c index 42eb215b3aa..1234621ee7f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/exp10m1.c +++ b/Build/source/libs/mpfr/mpfr-src/src/exp10m1.c @@ -69,8 +69,8 @@ mpfr_exp10m1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_IS_SINGULAR (x)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/exp2.c b/Build/source/libs/mpfr/mpfr-src/src/exp2.c index b64546bb339..25aa005dce7 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/exp2.c +++ b/Build/source/libs/mpfr/mpfr-src/src/exp2.c @@ -52,8 +52,8 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/exp2m1.c b/Build/source/libs/mpfr/mpfr-src/src/exp2m1.c index 4dc4221bdb4..025df6f142d 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/exp2m1.c +++ b/Build/source/libs/mpfr/mpfr-src/src/exp2m1.c @@ -74,8 +74,8 @@ mpfr_exp2m1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_IS_SINGULAR (x)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/exp3.c b/Build/source/libs/mpfr/mpfr-src/src/exp3.c index 890d7e900d6..04d5b11c443 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/exp3.c +++ b/Build/source/libs/mpfr/mpfr-src/src/exp3.c @@ -171,8 +171,8 @@ mpfr_exp_3 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (ziv_loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); MPFR_SAVE_EXPO_MARK (expo); diff --git a/Build/source/libs/mpfr/mpfr-src/src/exp_2.c b/Build/source/libs/mpfr/mpfr-src/src/exp_2.c index b59ad02bee4..20393149749 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/exp_2.c +++ b/Build/source/libs/mpfr/mpfr-src/src/exp_2.c @@ -87,8 +87,8 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); expx = MPFR_GET_EXP (x); diff --git a/Build/source/libs/mpfr/mpfr-src/src/expm1.c b/Build/source/libs/mpfr/mpfr-src/src/expm1.c index a8b8d5a5358..ec265416f5b 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/expm1.c +++ b/Build/source/libs/mpfr/mpfr-src/src/expm1.c @@ -35,8 +35,8 @@ mpfr_expm1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/fma.c b/Build/source/libs/mpfr/mpfr-src/src/fma.c index 5ea26addab2..d9c6ded6d3f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/fma.c +++ b/Build/source/libs/mpfr/mpfr-src/src/fma.c @@ -109,11 +109,11 @@ mpfr_fma (mpfr_ptr s, mpfr_srcptr x, mpfr_srcptr y, mpfr_srcptr z, MPFR_GROUP_DECL(group); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg y[%Pu]=%.*Rg z[%Pu]=%.*Rg rnd=%d", + (("x[%Pd]=%.*Rg y[%Pd]=%.*Rg z[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, mpfr_get_prec (y), mpfr_log_prec, y, mpfr_get_prec (z), mpfr_log_prec, z, rnd_mode), - ("s[%Pu]=%.*Rg inexact=%d", + ("s[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (s), mpfr_log_prec, s, inexact)); /* particular cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/fmma.c b/Build/source/libs/mpfr/mpfr-src/src/fmma.c index f697a9094d2..0d07f205603 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/fmma.c +++ b/Build/source/libs/mpfr/mpfr-src/src/fmma.c @@ -36,12 +36,12 @@ mpfr_fmma_aux (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c, MPFR_TMP_DECL(marker); MPFR_LOG_FUNC - (("a[%Pu]=%.*Rg b[%Pu]=%.*Rg c[%Pu]=%.*Rg d[%Pu]=%.*Rg rnd=%d neg=%d", + (("a[%Pd]=%.*Rg b[%Pd]=%.*Rg c[%Pd]=%.*Rg d[%Pd]=%.*Rg rnd=%d neg=%d", mpfr_get_prec (a), mpfr_log_prec, a, mpfr_get_prec (b), mpfr_log_prec, b, mpfr_get_prec (c), mpfr_log_prec, c, mpfr_get_prec (d), mpfr_log_prec, d, rnd, neg), - ("z[%Pu]=%.*Rg inex=%d", + ("z[%Pd]=%.*Rg inex=%d", mpfr_get_prec (z), mpfr_log_prec, z, inex)); MPFR_TMP_MARK (marker); diff --git a/Build/source/libs/mpfr/mpfr-src/src/fmod_ui.c b/Build/source/libs/mpfr/mpfr-src/src/fmod_ui.c index f1e2fa18371..76984276689 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/fmod_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/fmod_ui.c @@ -29,9 +29,9 @@ mpfr_fmod_ui (mpfr_ptr r, mpfr_srcptr x, unsigned long u, mpfr_rnd_t rnd_mode) int inex; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%lu rnd=%d", + (("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(r), mpfr_log_prec, r, inex)); if (MPFR_UNLIKELY (u != 0)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/frexp.c b/Build/source/libs/mpfr/mpfr-src/src/frexp.c index e4e8cecd39c..a9ae5f3f732 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/frexp.c +++ b/Build/source/libs/mpfr/mpfr-src/src/frexp.c @@ -30,8 +30,8 @@ mpfr_frexp (mpfr_exp_t *exp, mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) MPFR_BLOCK_DECL (flags); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), - ("y[%Pu]=%.*Rg exp=%" MPFR_EXP_FSPEC "d inex=%d", mpfr_get_prec (y), + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), + ("y[%Pd]=%.*Rg exp=%" MPFR_EXP_FSPEC "d inex=%d", mpfr_get_prec (y), mpfr_log_prec, y, (mpfr_eexp_t) *exp, inex)); if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/gamma.c b/Build/source/libs/mpfr/mpfr-src/src/gamma.c index f18eb68d338..f8b2bdc487f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/gamma.c +++ b/Build/source/libs/mpfr/mpfr-src/src/gamma.c @@ -122,8 +122,8 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("gamma[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("gamma[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (gamma), mpfr_log_prec, gamma, inex)); /* Trivial cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/get_str.c b/Build/source/libs/mpfr/mpfr-src/src/get_str.c index f62df89e970..af62651b648 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/get_str.c +++ b/Build/source/libs/mpfr/mpfr-src/src/get_str.c @@ -2605,7 +2605,7 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x, /* otherwise err is such that |x*b^(m-g)-a*2^exp_a| < 2^(err+exp_a) */ MPFR_LOG_FUNC - (("b=%d m=%zu x[%Pu]=%.*Rg rnd=%d", + (("b=%d m=%zu x[%Pd]=%.*Rg rnd=%d", b, m, mpfr_get_prec (x), mpfr_log_prec, x, rnd), ("flags=%lx", (unsigned long) __gmpfr_flags)); diff --git a/Build/source/libs/mpfr/mpfr-src/src/hypot.c b/Build/source/libs/mpfr/mpfr-src/src/hypot.c index 0d0ba0aae54..726c0d33208 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/hypot.c +++ b/Build/source/libs/mpfr/mpfr-src/src/hypot.c @@ -43,10 +43,10 @@ mpfr_hypot (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode) MPFR_BLOCK_DECL (flags); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg y[%Pu]=%.*Rg rnd=%d", + (("x[%Pd]=%.*Rg y[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, mpfr_get_prec (y), mpfr_log_prec, y, rnd_mode), - ("z[%Pu]=%.*Rg inexact=%d", + ("z[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (z), mpfr_log_prec, z, inexact)); /* particular cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/inp_str.c b/Build/source/libs/mpfr/mpfr-src/src/inp_str.c index 32e079fa08f..d34c3ee5f46 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/inp_str.c +++ b/Build/source/libs/mpfr/mpfr-src/src/inp_str.c @@ -69,15 +69,25 @@ mpfr_inp_str (mpfr_ptr rop, FILE *stream, int base, mpfr_rnd_t rnd_mode) if (c == EOF || isspace (c)) break; str[str_size++] = (unsigned char) c; + /* If c is '\0' (while not being a whitespace character), the word will + not have a valid format. But in the context of a string in memory, + '\0' is a terminating null character. So, to avoid ending with a + valid string format (like "1" with ignored characters after the + terminating null character), we need to make sure that the string + does not have a valid format; so let's start it with '*'. Note + that we should read the full word, so we cannot break. */ + if (MPFR_UNLIKELY (c == '\0')) + str[0] = '*'; if (str_size == (size_t) -1) break; c = getc (stream); } - /* FIXME: The use of ungetc has been deprecated since C99 when it - occurs at the beginning of a binary stream, and this may happen - on /dev/null. One could add a "if (c != EOF)" test, but let's - wait for some discussion in comp.std.c first... */ - ungetc (c, stream); + /* The use of ungetc has been deprecated since C99 when it occurs at the + beginning of a binary stream, and this may happen on /dev/null. Here, + this is possible only for c == EOF. The condition "if (c != EOF)" below + is just there to handle this case. */ + if (c != EOF) + ungetc (c, stream); if (MPFR_UNLIKELY (str_size == (size_t) -1 || str_size == 0 || (c == EOF && ! feof (stream)))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/jn.c b/Build/source/libs/mpfr/mpfr-src/src/jn.c index 5a92f9cee48..459b1042079 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/jn.c +++ b/Build/source/libs/mpfr/mpfr-src/src/jn.c @@ -95,8 +95,8 @@ mpfr_jn (mpfr_ptr res, long n, mpfr_srcptr z, mpfr_rnd_t r) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("n=%d x[%Pu]=%.*Rg rnd=%d", n, mpfr_get_prec (z), mpfr_log_prec, z, r), - ("res[%Pu]=%.*Rg inexact=%d", + (("n=%d x[%Pd]=%.*Rg rnd=%d", n, mpfr_get_prec (z), mpfr_log_prec, z, r), + ("res[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (res), mpfr_log_prec, res, inex)); absn = SAFE_ABS (unsigned long, n); diff --git a/Build/source/libs/mpfr/mpfr-src/src/li2.c b/Build/source/libs/mpfr/mpfr-src/src/li2.c index 901894e47b9..91f23283a47 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/li2.c +++ b/Build/source/libs/mpfr/mpfr-src/src/li2.c @@ -221,8 +221,8 @@ mpfr_li2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/lngamma.c b/Build/source/libs/mpfr/mpfr-src/src/lngamma.c index b68044a0182..7e89e92a39f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/lngamma.c +++ b/Build/source/libs/mpfr/mpfr-src/src/lngamma.c @@ -34,8 +34,8 @@ static void mpfr_gamma_alpha (mpfr_ptr s, mpfr_prec_t p) { MPFR_LOG_FUNC - (("p=%Pu", p), - ("s[%Pu]=%.*Rg", mpfr_get_prec (s), mpfr_log_prec, s)); + (("p=%Pd", p), + ("s[%Pd]=%.*Rg", mpfr_get_prec (s), mpfr_log_prec, s)); if (p <= 100) mpfr_set_ui_2exp (s, 614, -10, MPFR_RNDN); /* about 0.6 */ @@ -179,8 +179,8 @@ GAMMA_FUNC (mpfr_ptr y, mpfr_srcptr z0, mpfr_rnd_t rnd) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (z0), mpfr_log_prec, z0, rnd), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (z0), mpfr_log_prec, z0, rnd), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); compared = mpfr_cmp_ui (z0, 1); @@ -723,8 +723,8 @@ mpfr_lngamma (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) int inex; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inex)); /* special cases */ @@ -763,8 +763,8 @@ mpfr_lgamma (mpfr_ptr y, int *signp, mpfr_srcptr x, mpfr_rnd_t rnd) int inex; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), - ("y[%Pu]=%.*Rg signp=%d inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), + ("y[%Pd]=%.*Rg signp=%d inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, *signp, inex)); *signp = 1; /* most common case */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/log.c b/Build/source/libs/mpfr/mpfr-src/src/log.c index 677fcc3d6e4..8f00167410f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/log.c +++ b/Build/source/libs/mpfr/mpfr-src/src/log.c @@ -50,8 +50,8 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mpfr_rnd_t rnd_mode) MPFR_GROUP_DECL(group); MPFR_LOG_FUNC - (("a[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (a), mpfr_log_prec, a, rnd_mode), - ("r[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, + (("a[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (a), mpfr_log_prec, a, rnd_mode), + ("r[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, inexact)); /* Special cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/log10.c b/Build/source/libs/mpfr/mpfr-src/src/log10.c index a045ef155bc..ba2a6b7a0ff 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/log10.c +++ b/Build/source/libs/mpfr/mpfr-src/src/log10.c @@ -35,8 +35,8 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("a[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (a), mpfr_log_prec, a, rnd_mode), - ("r[%Pu]=%.*Rg inexact=%d", + (("a[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (a), mpfr_log_prec, a, rnd_mode), + ("r[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, inexact)); /* If a is NaN, the result is NaN */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/log10p1.c b/Build/source/libs/mpfr/mpfr-src/src/log10p1.c index 01856442c2f..811cece9291 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/log10p1.c +++ b/Build/source/libs/mpfr/mpfr-src/src/log10p1.c @@ -129,8 +129,8 @@ mpfr_log10p1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/log1p.c b/Build/source/libs/mpfr/mpfr-src/src/log1p.c index 87f35e07c57..7f26e66d375 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/log1p.c +++ b/Build/source/libs/mpfr/mpfr-src/src/log1p.c @@ -106,8 +106,8 @@ mpfr_log1p (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/log2.c b/Build/source/libs/mpfr/mpfr-src/src/log2.c index 310ec985251..56b3a2f2c2a 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/log2.c +++ b/Build/source/libs/mpfr/mpfr-src/src/log2.c @@ -33,8 +33,8 @@ mpfr_log2 (mpfr_ptr r, mpfr_srcptr a, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("a[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (a), mpfr_log_prec, a, rnd_mode), - ("r[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, + (("a[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (a), mpfr_log_prec, a, rnd_mode), + ("r[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (a))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/log2p1.c b/Build/source/libs/mpfr/mpfr-src/src/log2p1.c index ac0bdd6170d..20a9c663f63 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/log2p1.c +++ b/Build/source/libs/mpfr/mpfr-src/src/log2p1.c @@ -89,8 +89,8 @@ mpfr_log2p1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/modf.c b/Build/source/libs/mpfr/mpfr-src/src/modf.c index 5f1377bb32f..fc4f6a0e35a 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/modf.c +++ b/Build/source/libs/mpfr/mpfr-src/src/modf.c @@ -31,9 +31,9 @@ mpfr_modf (mpfr_ptr iop, mpfr_ptr fop, mpfr_srcptr op, mpfr_rnd_t rnd_mode) int inexi, inexf; MPFR_LOG_FUNC - (("op[%Pu]=%.*Rg rnd=%d", + (("op[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (op), mpfr_log_prec, op, rnd_mode), - ("iop[%Pu]=%.*Rg fop[%Pu]=%.*Rg", + ("iop[%Pd]=%.*Rg fop[%Pd]=%.*Rg", mpfr_get_prec (iop), mpfr_log_prec, iop, mpfr_get_prec (fop), mpfr_log_prec, fop)); diff --git a/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h b/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h index 098fd956f44..4cae6254860 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h +++ b/Build/source/libs/mpfr/mpfr-src/src/mpfr-gmp.h @@ -468,14 +468,22 @@ void *alloca (size_t); and outputs may overlap. */ #ifndef udiv_qr_3by2 -#define udiv_qr_3by2(q, r1, r0, n2, n1, n0, d1, d0, dinv) \ +# ifdef MPFR_USE_MINI_GMP +/* Avoid integer overflow on int in case of integer promotion + (when mp_limb_t is shorter than int). Note that unsigned long + may be longer than necessary, but GCC seems to optimize. */ +# define OP_CAST (unsigned long) +# else +# define OP_CAST +# endif +# define udiv_qr_3by2(q, r1, r0, n2, n1, n0, d1, d0, dinv) \ do { \ mp_limb_t _q0, _t1, _t0, _mask; \ umul_ppmm ((q), _q0, (n2), (dinv)); \ add_ssaaaa ((q), _q0, (q), _q0, (n2), (n1)); \ \ /* Compute the two most significant limbs of n - q'd */ \ - (r1) = (n1) - (d1) * (q); \ + (r1) = (n1) - OP_CAST (d1) * (q); \ (r0) = (n0); \ sub_ddmmss ((r1), (r0), (r1), (r0), (d1), (d0)); \ umul_ppmm (_t1, _t0, (d0), (q)); \ diff --git a/Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h b/Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h index fe54cecab26..5019ca68bc1 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h +++ b/Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h @@ -1655,8 +1655,10 @@ do { \ this can be found in practice: https://reviews.llvm.org/D27167 says: "I found this problem on FreeBSD 11, where thousands_sep in fr_FR.UTF-8 is a no-break space (U+00A0)." - Note, however, that this is not allowed by the C standard, which just - says "character" and not "multibyte character". + Under Linux, this is U+202F NARROW NO-BREAK SPACE (e2 80 af). + And in the ps_AF locale, + decimal_point = U+066B ARABIC DECIMAL SEPARATOR (d9 ab) + thousands_sep = U+066C ARABIC THOUSANDS SEPARATOR (d9 ac) In the mean time, in case of non-single-byte character, revert to the default value. */ #if MPFR_LCONV_DPTS @@ -2192,7 +2194,7 @@ __MPFR_DECLSPEC extern mpfr_prec_t mpfr_log_prec; while (0) #define MPFR_LOG_VAR(x) \ - LOG_PRINT (MPFR_LOG_INTERNAL_F, "%s.%d:%s[%#Pu]=%.*Rg\n", __func__, \ + LOG_PRINT (MPFR_LOG_INTERNAL_F, "%s.%d:%s[%#Pd]=%.*Rg\n", __func__, \ (int) __LINE__, #x, mpfr_get_prec (x), mpfr_log_prec, x) #define MPFR_LOG_MSG2(format, ...) \ diff --git a/Build/source/libs/mpfr/mpfr-src/src/mpfr-thread.h b/Build/source/libs/mpfr/mpfr-src/src/mpfr-thread.h index a3099b0d937..344f1e43bf5 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mpfr-thread.h +++ b/Build/source/libs/mpfr/mpfr-src/src/mpfr-thread.h @@ -64,10 +64,13 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define MPFR_LOCK_DECL(_lock) \ mtx_t _lock; -#define MPFR_LOCK_C(E) \ - do { \ - if ((E) != thrd_success) \ - abort (); \ +#define MPFR_LOCK_C(E) \ + do { \ + if ((E) != thrd_success) \ + { \ + fprintf (stderr, "MPFR lock failure\n"); \ + abort (); \ + } \ } while (0) #define MPFR_LOCK_INIT(_lock) MPFR_LOCK_C(mtx_init(&(_lock), mtx_plain)) @@ -107,10 +110,13 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define MPFR_LOCK_DECL(_lock) \ pthread_rwlock_t _lock; -#define MPFR_LOCK_C(E) \ - do { \ - if ((E) != 0) \ - abort (); \ +#define MPFR_LOCK_C(E) \ + do { \ + if ((E) != 0) \ + { \ + fprintf (stderr, "MPFR lock failure\n"); \ + abort (); \ + } \ } while (0) #define MPFR_LOCK_INIT(_lock) MPFR_LOCK_C(pthread_rwlock_init(&(_lock), NULL)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/mpfr.h b/Build/source/libs/mpfr/mpfr-src/src/mpfr.h index 4610c67bb17..6322670c440 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mpfr.h +++ b/Build/source/libs/mpfr/mpfr-src/src/mpfr.h @@ -26,8 +26,8 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., /* Define MPFR version number */ #define MPFR_VERSION_MAJOR 4 #define MPFR_VERSION_MINOR 2 -#define MPFR_VERSION_PATCHLEVEL 0 -#define MPFR_VERSION_STRING "4.2.0" +#define MPFR_VERSION_PATCHLEVEL 1 +#define MPFR_VERSION_STRING "4.2.1" /* User macros: MPFR_USE_FILE: Define it to make MPFR define functions dealing diff --git a/Build/source/libs/mpfr/mpfr-src/src/mul.c b/Build/source/libs/mpfr/mpfr-src/src/mul.c index 6f319040b03..fef4a880038 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mul.c +++ b/Build/source/libs/mpfr/mpfr-src/src/mul.c @@ -740,10 +740,10 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) MPFR_TMP_DECL (marker); MPFR_LOG_FUNC - (("b[%Pu]=%.*Rg c[%Pu]=%.*Rg rnd=%d", + (("b[%Pd]=%.*Rg c[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (b), mpfr_log_prec, b, mpfr_get_prec (c), mpfr_log_prec, c, rnd_mode), - ("a[%Pu]=%.*Rg inexact=%d", + ("a[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (a), mpfr_log_prec, a, inexact)); /* deal with special cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/mul_2si.c b/Build/source/libs/mpfr/mpfr-src/src/mul_2si.c index 7d0038c74a3..eb322f480d1 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mul_2si.c +++ b/Build/source/libs/mpfr/mpfr-src/src/mul_2si.c @@ -28,9 +28,9 @@ mpfr_mul_2si (mpfr_ptr y, mpfr_srcptr x, long int n, mpfr_rnd_t rnd_mode) int inexact; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg n=%ld rnd=%d", + (("x[%Pd]=%.*Rg n=%ld rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, n, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/mul_2ui.c b/Build/source/libs/mpfr/mpfr-src/src/mul_2ui.c index b76f8579708..8cf64fd640e 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mul_2ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/mul_2ui.c @@ -28,9 +28,9 @@ mpfr_mul_2ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int n, mpfr_rnd_t rnd_mod int inexact; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg n=%lu rnd=%d", + (("x[%Pd]=%.*Rg n=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, n, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); inexact = (y != x) ? mpfr_set (y, x, rnd_mode) : 0; diff --git a/Build/source/libs/mpfr/mpfr-src/src/mul_d.c b/Build/source/libs/mpfr/mpfr-src/src/mul_d.c index e0fe1e7e981..257a4390929 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mul_d.c +++ b/Build/source/libs/mpfr/mpfr-src/src/mul_d.c @@ -32,9 +32,9 @@ mpfr_mul_d (mpfr_ptr a, mpfr_srcptr b, double c, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("b[%Pu]=%.*Rg c=%.20g rnd=%d", + (("b[%Pd]=%.*Rg c=%.20g rnd=%d", mpfr_get_prec(b), mpfr_log_prec, b, c, rnd_mode), - ("a[%Pu]=%.*Rg inexact=%d", + ("a[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (a), mpfr_log_prec, a, inexact)); MPFR_SAVE_EXPO_MARK (expo); diff --git a/Build/source/libs/mpfr/mpfr-src/src/pow.c b/Build/source/libs/mpfr/mpfr-src/src/pow.c index a7ba3ee1ff3..302e5635cd0 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/pow.c +++ b/Build/source/libs/mpfr/mpfr-src/src/pow.c @@ -64,7 +64,7 @@ mpfr_pow_is_exact (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, MPFR_ASSERTD (d < 0); /* Compute a,b such that x=a*2^b. - Since a comes from a regular MPFR number, due to the constrainst on the + Since a comes from a regular MPFR number, due to the constraints on the exponent and the precision, there can be no integer overflow below. */ mpz_init (a); b = mpfr_get_z_2exp (a, x); @@ -131,14 +131,13 @@ mpfr_pow_general (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, /* Declaration of the size variable */ mpfr_prec_t Nz = MPFR_PREC(z); /* target precision */ mpfr_prec_t Nt; /* working precision */ - mpfr_exp_t err; /* error */ MPFR_ZIV_DECL (ziv_loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg y[%Pu]=%.*Rg rnd=%d", + (("x[%Pd]=%.*Rg y[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, mpfr_get_prec (y), mpfr_log_prec, y, rnd_mode), - ("z[%Pu]=%.*Rg inexact=%d", + ("z[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (z), mpfr_log_prec, z, inexact)); /* We put the absolute value of x in absx, pointing to the significand @@ -171,12 +170,14 @@ mpfr_pow_general (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, MPFR_ZIV_INIT (ziv_loop, Nt); for (;;) { + mpfr_exp_t err, exp_t; MPFR_BLOCK_DECL (flags1); /* compute exp(y*ln|x|), using MPFR_RNDU to get an upper bound, so that we can detect underflows. */ mpfr_log (t, absx, MPFR_IS_NEG (y) ? MPFR_RNDD : MPFR_RNDU); /* ln|x| */ mpfr_mul (t, y, t, MPFR_RNDU); /* y*ln|x| */ + exp_t = MPFR_GET_EXP (t); if (k_non_zero) { MPFR_LOG_MSG (("subtract k * ln(2)\n", 0)); @@ -188,14 +189,16 @@ mpfr_pow_general (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, MPFR_LOG_VAR (t); } /* estimate of the error -- see pow function in algorithms.tex. - The error on t is at most 1/2 + 3*2^(EXP(t)+1) ulps, which is - <= 2^(EXP(t)+3) for EXP(t) >= -1, and <= 2 ulps for EXP(t) <= -2. + The error on t before the subtraction of k*log(2) is at most + 1/2 + 3*2^(EXP(t)+1) ulps, which is <= 2^(EXP(t)+3) for EXP(t) >= -1, + and <= 2 ulps for EXP(t) <= -2. Additional error if k_no_zero: treal = t * errk, with 1 - |k| * 2^(-Nt) <= exp(-|k| * 2^(-Nt)) <= errk <= 1, i.e., additional absolute error <= 2^(EXP(k)+EXP(t)-Nt). - Total error <= 2^err1 + 2^err2 <= 2^(max(err1,err2)+1). */ - err = MPFR_NOTZERO (t) && MPFR_GET_EXP (t) >= -1 ? - MPFR_GET_EXP (t) + 3 : 1; + Total ulp error <= 2^err1 + 2^err2 <= 2^(max(err1,err2)+1), + where err1 = EXP(t)+3 for EXP(t) >= -1, and 1 otherwise, + and err2 = EXP(k). */ + err = MPFR_NOTZERO (t) && exp_t >= -1 ? exp_t + 3 : 1; if (k_non_zero) { if (MPFR_GET_EXP (k) > err) @@ -328,11 +331,17 @@ mpfr_pow_general (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, */ if (rnd_mode == MPFR_RNDN && inexact < 0 && lk < 0 && MPFR_GET_EXP (z) == __gmpfr_emin - 1 - lk && mpfr_powerof2_raw (z)) - /* Rounding to nearest, real result > z * 2^k = 2^(emin - 2), - * underflow case: we will obtain the correct result and exceptions - * by replacing z by nextabove(z). - */ - mpfr_nextabove (z); + /* Rounding to nearest, exact result > z * 2^k = 2^(emin - 2), + * and underflow case because the rounded result assuming an + * unbounded exponent range is 2^(emin - 2). We need to round + * to 2^(emin - 1), i.e. to round toward +inf. + * Note: the old code was using "mpfr_nextabove (z);" instead of + * setting rnd_mode to MPFR_RNDU for the call to mpfr_mul_2si, but + * this was incorrect in precision 1 because in this precision, + * mpfr_nextabove gave 2^(emin - 1), which is representable, + * so that mpfr_mul_2si did not generate the wanted underflow + * (the value was correct, but the underflow flag was missing). */ + rnd_mode = MPFR_RNDU; MPFR_CLEAR_FLAGS (); inex2 = mpfr_mul_2si (z, z, lk, rnd_mode); if (inex2) /* underflow or overflow */ @@ -385,10 +394,10 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg y[%Pu]=%.*Rg rnd=%d", + (("x[%Pd]=%.*Rg y[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, mpfr_get_prec (y), mpfr_log_prec, y, rnd_mode), - ("z[%Pu]=%.*Rg inexact=%d", + ("z[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (z), mpfr_log_prec, z, inexact)); if (MPFR_ARE_SINGULAR (x, y)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/pow_si.c b/Build/source/libs/mpfr/mpfr-src/src/pow_si.c index 22cda32e129..c1f522f5763 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/pow_si.c +++ b/Build/source/libs/mpfr/mpfr-src/src/pow_si.c @@ -43,9 +43,9 @@ int POW_S (mpfr_ptr y, mpfr_srcptr x, TYPE n, mpfr_rnd_t rnd) { MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg n=%" FSPEC "d rnd=%d", + (("x[%Pd]=%.*Rg n=%" FSPEC "d rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, n, rnd), - ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); + ("y[%Pd]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); if (n >= 0) return POW_U (y, x, n, rnd); diff --git a/Build/source/libs/mpfr/mpfr-src/src/pow_ui.c b/Build/source/libs/mpfr/mpfr-src/src/pow_ui.c index b59399135c1..d82e68ffdc5 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/pow_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/pow_ui.c @@ -44,9 +44,9 @@ POW_U (mpfr_ptr y, mpfr_srcptr x, UTYPE n, mpfr_rnd_t rnd) MPFR_BLOCK_DECL (flags); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg n=%" FSPEC "u rnd=%d", + (("x[%Pd]=%.*Rg n=%" FSPEC "u rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, n, rnd), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* x^0 = 1 for any x, even a NaN */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/pow_z.c b/Build/source/libs/mpfr/mpfr-src/src/pow_z.c index 2388ed081df..6f930ac12f2 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/pow_z.c +++ b/Build/source/libs/mpfr/mpfr-src/src/pow_z.c @@ -41,9 +41,9 @@ mpfr_pow_pos_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z, mpfr_rnd_t rnd, int cr) MPFR_BLOCK_DECL (flags); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg z=%Zd rnd=%d cr=%d", + (("x[%Pd]=%.*Rg z=%Zd rnd=%d cr=%d", mpfr_get_prec (x), mpfr_log_prec, x, z, rnd, cr), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); MPFR_ASSERTD (mpz_sgn (z) != 0); @@ -171,9 +171,9 @@ mpfr_pow_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z, mpfr_rnd_t rnd) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg z=%Zd rnd=%d", + (("x[%Pd]=%.*Rg z=%Zd rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, z, rnd), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* x^0 = 1 for any x, even a NaN */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/rec_sqrt.c b/Build/source/libs/mpfr/mpfr-src/src/rec_sqrt.c index c6ca40ba107..67c98557d59 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/rec_sqrt.c +++ b/Build/source/libs/mpfr/mpfr-src/src/rec_sqrt.c @@ -463,10 +463,11 @@ mpfr_rec_sqrt (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode) int s, cy, inex; mpfr_limb_ptr x; MPFR_TMP_DECL(marker); + MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (u), mpfr_log_prec, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, inex)); + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (u), mpfr_log_prec, u, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, inex)); /* special values */ if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(u))) @@ -530,6 +531,7 @@ mpfr_rec_sqrt (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode) wp = rp + 11; if (wp < rn * GMP_NUMB_BITS) wp = rn * GMP_NUMB_BITS; + MPFR_ZIV_INIT (loop, wp); for (;;) { MPFR_TMP_MARK (marker); @@ -561,8 +563,9 @@ mpfr_rec_sqrt (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode) } MPFR_TMP_FREE(marker); - wp += GMP_NUMB_BITS; + MPFR_ZIV_NEXT (loop, wp); } + MPFR_ZIV_FREE (loop); cy = mpfr_round_raw (MPFR_MANT(r), x, wp, 0, rp, rnd_mode, &inex); MPFR_EXP(r) = - (MPFR_EXP(u) - 1 - s) / 2; if (MPFR_UNLIKELY(cy != 0)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/reldiff.c b/Build/source/libs/mpfr/mpfr-src/src/reldiff.c index 832bf4d2b5e..5adf6a351ed 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/reldiff.c +++ b/Build/source/libs/mpfr/mpfr-src/src/reldiff.c @@ -30,31 +30,25 @@ mpfr_reldiff (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) if (MPFR_ARE_SINGULAR (b, c)) { - if (MPFR_IS_NAN(b) || MPFR_IS_NAN(c)) + if (MPFR_IS_NAN (b) || MPFR_IS_INF (b) || MPFR_IS_NAN (c) || + (MPFR_IS_ZERO (b) && MPFR_IS_ZERO (c))) { - MPFR_SET_NAN(a); + MPFR_SET_NAN (a); return; } - else if (MPFR_IS_INF(b)) - { - if (MPFR_IS_INF (c) && (MPFR_SIGN (c) == MPFR_SIGN (b))) - MPFR_SET_ZERO(a); - else - MPFR_SET_NAN(a); - return; - } - else if (MPFR_IS_INF(c)) + if (MPFR_IS_ZERO (b) || MPFR_IS_INF (c)) { MPFR_SET_SAME_SIGN (a, b); MPFR_SET_INF (a); return; } - else if (MPFR_IS_ZERO(b)) /* reldiff = abs(c)/c = sign(c) */ - { - mpfr_set_si (a, MPFR_INT_SIGN (c), rnd_mode); - return; - } - /* Fall through */ + /* The case c = 0 with b regular, which should give sign(b) exactly, + cannot be optimized here as it is documented in the MPFR manual + that this function just computes abs(b-c)/b using the precision + of a and the rounding mode rnd_mode for all operations. So let's + prefer the potentially "incorrect" result. Note that the correct + result is not necessarily better because if could break properties + (like monotonicity?) implied by the documentation. */ } if (a == b) @@ -64,8 +58,8 @@ mpfr_reldiff (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) } mpfr_sub (a, b, c, rnd_mode); - mpfr_abs (a, a, rnd_mode); /* for compatibility with MPF */ - mpfr_div (a, a, (a == b) ? b_copy : b, rnd_mode); + MPFR_SET_SIGN (a, 1); + mpfr_div (a, a, a == b ? b_copy : b, rnd_mode); if (a == b) mpfr_clear (b_copy); diff --git a/Build/source/libs/mpfr/mpfr-src/src/root.c b/Build/source/libs/mpfr/mpfr-src/src/root.c index 386846ad2c6..e2e3a599d1c 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/root.c +++ b/Build/source/libs/mpfr/mpfr-src/src/root.c @@ -54,9 +54,9 @@ mpfr_rootn_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long k, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg k=%lu rnd=%d", + (("x[%Pd]=%.*Rg k=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, k, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (k <= 1)) @@ -306,9 +306,9 @@ mpfr_rootn_si (mpfr_ptr y, mpfr_srcptr x, long k, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg k=%lu rnd=%d", + (("x[%Pd]=%.*Rg k=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, k, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (k >= 0) @@ -441,9 +441,9 @@ int mpfr_root (mpfr_ptr y, mpfr_srcptr x, unsigned long k, mpfr_rnd_t rnd_mode) { MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg k=%lu rnd=%d", + (("x[%Pd]=%.*Rg k=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, k, rnd_mode), - ("y[%Pu]=%.*Rg", + ("y[%Pd]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); /* Like mpfr_rootn_ui... */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/set_prec.c b/Build/source/libs/mpfr/mpfr-src/src/set_prec.c index 54d610d6776..d673bea45d6 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/set_prec.c +++ b/Build/source/libs/mpfr/mpfr-src/src/set_prec.c @@ -27,7 +27,7 @@ mpfr_set_prec (mpfr_ptr x, mpfr_prec_t p) { mp_size_t xsize, xoldsize; - MPFR_LOG_MSG (("prec=%Pu\n", p)); + MPFR_LOG_MSG (("prec=%Pd\n", p)); /* first, check if p is correct */ MPFR_ASSERTN (MPFR_PREC_COND (p)); diff --git a/Build/source/libs/mpfr/mpfr-src/src/si_op.c b/Build/source/libs/mpfr/mpfr-src/src/si_op.c index 71fa91fcf64..3925a366585 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/si_op.c +++ b/Build/source/libs/mpfr/mpfr-src/src/si_op.c @@ -33,9 +33,9 @@ mpfr_add_si (mpfr_ptr y, mpfr_srcptr x, long int u, mpfr_rnd_t rnd_mode) int res; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%ld rnd=%d", + (("x[%Pd]=%.*Rg u=%ld rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, res)); if (u >= 0) @@ -52,9 +52,9 @@ mpfr_sub_si (mpfr_ptr y, mpfr_srcptr x, long int u, mpfr_rnd_t rnd_mode) int res; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%ld rnd=%d", + (("x[%Pd]=%.*Rg u=%ld rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, res)); if (u >= 0) @@ -71,9 +71,9 @@ mpfr_si_sub (mpfr_ptr y, long int u, mpfr_srcptr x, mpfr_rnd_t rnd_mode) int res; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%ld rnd=%d", + (("x[%Pd]=%.*Rg u=%ld rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, res)); if (u >= 0) @@ -95,9 +95,9 @@ mpfr_mul_si (mpfr_ptr y, mpfr_srcptr x, long int u, mpfr_rnd_t rnd_mode) int res; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%ld rnd=%d", + (("x[%Pd]=%.*Rg u=%ld rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, res)); if (u >= 0) @@ -119,9 +119,9 @@ mpfr_div_si (mpfr_ptr y, mpfr_srcptr x, long int u, mpfr_rnd_t rnd_mode) int res; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%ld rnd=%d", + (("x[%Pd]=%.*Rg u=%ld rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, res)); if (u >= 0) @@ -142,9 +142,9 @@ mpfr_si_div (mpfr_ptr y, long int u, mpfr_srcptr x, mpfr_rnd_t rnd_mode) int res; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%ld rnd=%d", + (("x[%Pd]=%.*Rg u=%ld rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, res)); if (u >= 0) diff --git a/Build/source/libs/mpfr/mpfr-src/src/sin.c b/Build/source/libs/mpfr/mpfr-src/src/sin.c index 7b4252e6d55..82d78f72daf 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sin.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sin.c @@ -45,8 +45,8 @@ mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/sin_cos.c b/Build/source/libs/mpfr/mpfr-src/src/sin_cos.c index 3960759633b..034ed980271 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sin_cos.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sin_cos.c @@ -61,8 +61,8 @@ mpfr_sin_cos (mpfr_ptr y, mpfr_ptr z, mpfr_srcptr x, mpfr_rnd_t rnd_mode) } MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("sin[%Pu]=%.*Rg cos[%Pu]=%.*Rg", mpfr_get_prec(y), mpfr_log_prec, y, + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("sin[%Pd]=%.*Rg cos[%Pd]=%.*Rg", mpfr_get_prec(y), mpfr_log_prec, y, mpfr_get_prec (z), mpfr_log_prec, z)); MPFR_SAVE_EXPO_MARK (expo); diff --git a/Build/source/libs/mpfr/mpfr-src/src/sinh.c b/Build/source/libs/mpfr/mpfr-src/src/sinh.c index 6d54ba887cc..69efdf21c4c 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sinh.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sinh.c @@ -33,8 +33,8 @@ mpfr_sinh (mpfr_ptr y, mpfr_srcptr xt, mpfr_rnd_t rnd_mode) int inexact; MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (xt))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/sinh_cosh.c b/Build/source/libs/mpfr/mpfr-src/src/sinh_cosh.c index d3602cc8245..9566355616b 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sinh_cosh.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sinh_cosh.c @@ -37,9 +37,9 @@ mpfr_sinh_cosh (mpfr_ptr sh, mpfr_ptr ch, mpfr_srcptr xt, mpfr_rnd_t rnd_mode) MPFR_ASSERTN (sh != ch); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), - ("sh[%Pu]=%.*Rg ch[%Pu]=%.*Rg", + ("sh[%Pd]=%.*Rg ch[%Pd]=%.*Rg", mpfr_get_prec (sh), mpfr_log_prec, sh, mpfr_get_prec (ch), mpfr_log_prec, ch)); diff --git a/Build/source/libs/mpfr/mpfr-src/src/sinu.c b/Build/source/libs/mpfr/mpfr-src/src/sinu.c index 9e4e1ed017c..4c0aa20db9c 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sinu.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sinu.c @@ -43,9 +43,9 @@ mpfr_sinu (mpfr_ptr y, mpfr_srcptr x, unsigned long u, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg u=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, u, + ("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (u == 0 || MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/sqr.c b/Build/source/libs/mpfr/mpfr-src/src/sqr.c index 74309be6fcb..195019851c4 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sqr.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sqr.c @@ -516,8 +516,8 @@ mpfr_sqr (mpfr_ptr a, mpfr_srcptr b, mpfr_rnd_t rnd_mode) MPFR_TMP_DECL(marker); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (b), mpfr_log_prec, b, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (b), mpfr_log_prec, b, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (a), mpfr_log_prec, a, inexact)); /* deal with special cases */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/sqrt.c b/Build/source/libs/mpfr/mpfr-src/src/sqrt.c index 4252122a0fc..b6f293b2629 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sqrt.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sqrt.c @@ -517,8 +517,8 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode) MPFR_TMP_DECL(marker); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (u), mpfr_log_prec, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (u), mpfr_log_prec, u, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (r), mpfr_log_prec, r, inexact)); if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(u))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/sqrt_ui.c b/Build/source/libs/mpfr/mpfr-src/src/sqrt_ui.c index 318daaa03ad..18a612f90bb 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sqrt_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sqrt_ui.c @@ -30,7 +30,7 @@ mpfr_sqrt_ui (mpfr_ptr r, unsigned long u, mpfr_rnd_t rnd_mode) MPFR_LOG_FUNC (("u=%lu rnd=%d", u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec(r), mpfr_log_prec, r, inex)); if (u != 0) diff --git a/Build/source/libs/mpfr/mpfr-src/src/strtofr.c b/Build/source/libs/mpfr/mpfr-src/src/strtofr.c index a95d242bea2..7e699523caa 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/strtofr.c +++ b/Build/source/libs/mpfr/mpfr-src/src/strtofr.c @@ -242,7 +242,10 @@ parse_string (mpfr_ptr x, struct parsed_string *pstr, pstr->mantissa = NULL; /* Optional leading whitespace */ - while (isspace((unsigned char) *str)) str++; + /* For non-"C" locales, the ISO C standard allows isspace(0) to + return true. So we need to stop explicitly on '\0'. */ + while (*str != '\0' && isspace ((unsigned char) *str)) + str++; /* An optional sign `+' or `-' */ pstr->negative = (*str == '-'); @@ -425,7 +428,8 @@ parse_string (mpfr_ptr x, struct parsed_string *pstr, /* Remove 0's at the beginning and end of mantissa[0..prec-1] */ mant = pstr->mantissa; for ( ; (pstr->prec > 0) && (*mant == 0) ; mant++, pstr->prec--) - pstr->exp_base--; + if (MPFR_LIKELY (pstr->exp_base != MPFR_EXP_MIN)) + pstr->exp_base--; for ( ; (pstr->prec > 0) && (mant[pstr->prec - 1] == 0); pstr->prec--); pstr->mant = mant; @@ -738,7 +742,9 @@ parsed_string_to_mpfr (mpfr_ptr x, struct parsed_string *pstr, mpfr_rnd_t rnd) MPN_ZERO (y0, ysize); /* pstr_size - pstr->exp_base can overflow */ - MPFR_SADD_OVERFLOW (exp_z, (mpfr_exp_t) pstr_size, -pstr->exp_base, + exp_z = pstr->exp_base == MPFR_EXP_MIN ? + MPFR_EXP_MAX : -pstr->exp_base; /* avoid integer overflow */ + MPFR_SADD_OVERFLOW (exp_z, (mpfr_exp_t) pstr_size, exp_z, mpfr_exp_t, mpfr_uexp_t, MPFR_EXP_MIN, MPFR_EXP_MAX, goto underflow, goto overflow); @@ -862,7 +868,7 @@ parsed_string_to_mpfr (mpfr_ptr x, struct parsed_string *pstr, mpfr_rnd_t rnd) err = 0; } - MPFR_LOG_MSG (("exact = %d, err = %d, precx = %Pu\n", + MPFR_LOG_MSG (("exact = %d, err = %d, precx = %Pd\n", exact, err, precx)); /* at this point, result is an approximation rounded toward zero diff --git a/Build/source/libs/mpfr/mpfr-src/src/sub.c b/Build/source/libs/mpfr/mpfr-src/src/sub.c index c1d47e4e461..10978fc0466 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sub.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sub.c @@ -26,10 +26,10 @@ MPFR_HOT_FUNCTION_ATTR int mpfr_sub (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) { MPFR_LOG_FUNC - (("b[%Pu]=%.*Rg c[%Pu]=%.*Rg rnd=%d", + (("b[%Pd]=%.*Rg c[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (b), mpfr_log_prec, b, mpfr_get_prec (c), mpfr_log_prec, c, rnd_mode), - ("a[%Pu]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); + ("a[%Pd]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); if (MPFR_ARE_SINGULAR_OR_UBF (b,c)) { diff --git a/Build/source/libs/mpfr/mpfr-src/src/sub_d.c b/Build/source/libs/mpfr/mpfr-src/src/sub_d.c index 29f32502bc8..2c0c70e56b3 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sub_d.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sub_d.c @@ -32,9 +32,9 @@ mpfr_sub_d (mpfr_ptr a, mpfr_srcptr b, double c, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("b[%Pu]=%.*Rg c=%.20g rnd=%d", + (("b[%Pd]=%.*Rg c=%.20g rnd=%d", mpfr_get_prec (b), mpfr_log_prec, b, c, rnd_mode), - ("a[%Pu]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); + ("a[%Pd]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); MPFR_SAVE_EXPO_MARK (expo); diff --git a/Build/source/libs/mpfr/mpfr-src/src/sub_ui.c b/Build/source/libs/mpfr/mpfr-src/src/sub_ui.c index f57c11cdd48..4d4c550440b 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sub_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sub_ui.c @@ -28,9 +28,9 @@ int mpfr_sub_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mpfr_rnd_t rnd_mode) { MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg u=%lu rnd=%d", + (("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); + ("y[%Pd]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); /* (unsigned long) 0 is assumed to be a real 0 (unsigned) */ if (MPFR_UNLIKELY (u == 0)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/sum.c b/Build/source/libs/mpfr/mpfr-src/src/sum.c index 86e1fe4fa30..38de4c39924 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sum.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sum.c @@ -543,7 +543,7 @@ sum_aux (mpfr_ptr sum, const mpfr_ptr *x, unsigned long n, mpfr_rnd_t rnd, MPFR_LOG_FUNC (("n=%lu rnd=%d maxexp=%" MPFR_EXP_FSPEC "d rn=%lu", n, rnd, (mpfr_eexp_t) maxexp, rn), - ("sum[%Pu]=%.*Rg", mpfr_get_prec (sum), mpfr_log_prec, sum)); + ("sum[%Pd]=%.*Rg", mpfr_get_prec (sum), mpfr_log_prec, sum)); MPFR_ASSERTD (rn >= 3 && rn <= n); @@ -1268,7 +1268,7 @@ mpfr_sum (mpfr_ptr sum, const mpfr_ptr *x, unsigned long n, mpfr_rnd_t rnd) { MPFR_LOG_FUNC (("n=%lu rnd=%d", n, rnd), - ("sum[%Pu]=%.*Rg", mpfr_get_prec (sum), mpfr_log_prec, sum)); + ("sum[%Pd]=%.*Rg", mpfr_get_prec (sum), mpfr_log_prec, sum)); if (MPFR_UNLIKELY (n <= 2)) { diff --git a/Build/source/libs/mpfr/mpfr-src/src/tan.c b/Build/source/libs/mpfr/mpfr-src/src/tan.c index 79f1ad3b348..674c57e64a5 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/tan.c +++ b/Build/source/libs/mpfr/mpfr-src/src/tan.c @@ -35,8 +35,8 @@ mpfr_tan (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_GROUP_DECL (group); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/tanh.c b/Build/source/libs/mpfr/mpfr-src/src/tanh.c index 50ec630acfa..32cb72c703f 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/tanh.c +++ b/Build/source/libs/mpfr/mpfr-src/src/tanh.c @@ -32,8 +32,8 @@ mpfr_tanh (mpfr_ptr y, mpfr_srcptr xt, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", + (("x[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (xt), mpfr_log_prec, xt, rnd_mode), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); /* Special value checking */ diff --git a/Build/source/libs/mpfr/mpfr-src/src/tanu.c b/Build/source/libs/mpfr/mpfr-src/src/tanu.c index a53bb26b15b..330d5bcb425 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/tanu.c +++ b/Build/source/libs/mpfr/mpfr-src/src/tanu.c @@ -37,9 +37,9 @@ mpfr_tanu (mpfr_ptr y, mpfr_srcptr x, unsigned long u, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("x[%Pu]=%.*Rg u=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, u, + ("x[%Pd]=%.*Rg u=%lu rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, u, rnd_mode), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (y), mpfr_log_prec, y, inexact)); if (u == 0 || MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/ubf.c b/Build/source/libs/mpfr/mpfr-src/src/ubf.c index b2da806d119..2eac900d3d2 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/ubf.c +++ b/Build/source/libs/mpfr/mpfr-src/src/ubf.c @@ -74,10 +74,10 @@ void mpfr_ubf_mul_exact (mpfr_ubf_ptr a, mpfr_srcptr b, mpfr_srcptr c) { MPFR_LOG_FUNC - (("b[%Pu]=%.*Rg c[%Pu]=%.*Rg", + (("b[%Pd]=%.*Rg c[%Pd]=%.*Rg", mpfr_get_prec (b), mpfr_log_prec, b, mpfr_get_prec (c), mpfr_log_prec, c), - ("a[%Pu]=%.*Rg", + ("a[%Pd]=%.*Rg", mpfr_get_prec ((mpfr_ptr) a), mpfr_log_prec, a)); MPFR_ASSERTD ((mpfr_ptr) a != b); diff --git a/Build/source/libs/mpfr/mpfr-src/src/ui_div.c b/Build/source/libs/mpfr/mpfr-src/src/ui_div.c index 3a6339ca72d..4a2601b9ac2 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/ui_div.c +++ b/Build/source/libs/mpfr/mpfr-src/src/ui_div.c @@ -28,9 +28,9 @@ int mpfr_ui_div (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mpfr_rnd_t rnd_mode) { MPFR_LOG_FUNC - (("u=%lu x[%Pu]=%.*Rg rnd=%d", + (("u=%lu x[%Pd]=%.*Rg rnd=%d", u, mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg", mpfr_get_prec(y), mpfr_log_prec, y)); + ("y[%Pd]=%.*Rg", mpfr_get_prec(y), mpfr_log_prec, y)); if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x))) { diff --git a/Build/source/libs/mpfr/mpfr-src/src/ui_pow_ui.c b/Build/source/libs/mpfr/mpfr-src/src/ui_pow_ui.c index dd98ea2b13d..fc953c3820d 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/ui_pow_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/ui_pow_ui.c @@ -23,7 +23,7 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #include "mpfr-impl.h" int -mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int y, unsigned long int n, +mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int k, unsigned long int n, mpfr_rnd_t rnd) { mpfr_exp_t err; @@ -35,22 +35,28 @@ mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int y, unsigned long int n, MPFR_ZIV_DECL (loop); MPFR_SAVE_EXPO_DECL (expo); + MPFR_LOG_FUNC + (("k=%lu n=%lu rnd=%d", k, n, rnd), + ("y[%Pd]=%.*Rg inexact=%d", + mpfr_get_prec (x), mpfr_log_prec, x, inexact)); + if (MPFR_UNLIKELY (n <= 1)) { if (n == 1) - return mpfr_set_ui (x, y, rnd); /* y^1 = y */ + return mpfr_set_ui (x, k, rnd); /* k^1 = k */ else - return mpfr_set_ui (x, 1, rnd); /* y^0 = 1 for any y */ + return mpfr_set_ui (x, 1, rnd); /* k^0 = 1 for any k */ } - else if (MPFR_UNLIKELY (y <= 1)) + else if (MPFR_UNLIKELY (k <= 1)) { - if (y == 1) + if (k == 1) return mpfr_set_ui (x, 1, rnd); /* 1^n = 1 for any n > 0 */ else return mpfr_set_ui (x, 0, rnd); /* 0^n = 0 for any n > 0 */ } - for (size_n = 0, m = n; m; size_n++, m >>= 1); + for (size_n = 0, m = n; m != 0; size_n++, m >>= 1) + ; MPFR_SAVE_EXPO_MARK (expo); prec = MPFR_PREC (x) + 3 + size_n; @@ -60,23 +66,55 @@ mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int y, unsigned long int n, for (;;) { int i = size_n; + unsigned int inex_res; - inexact = mpfr_set_ui (res, y, MPFR_RNDU); + inex_res = mpfr_set_ui (res, k, MPFR_RNDU); err = 1; /* now 2^(i-1) <= n < 2^i: i=1+floor(log2(n)) */ for (i -= 2; i >= 0; i--) { - inexact |= mpfr_sqr (res, res, MPFR_RNDU); + inex_res |= mpfr_sqr (res, res, MPFR_RNDU); err++; if (n & (1UL << i)) - inexact |= mpfr_mul_ui (res, res, y, MPFR_RNDU); + inex_res |= mpfr_mul_ui (res, res, k, MPFR_RNDU); } + + if (MPFR_UNLIKELY (MPFR_IS_INF (res))) + { + mpfr_t kf; + mpz_t z; + int size_k; + MPFR_BLOCK_DECL (flags); + + /* Let's handle the overflow by calling mpfr_pow_z. + Alternatively, we could call mpfr_pow_ui; this would + need a bit shorter code below, but mpfr_pow_ui handles + the overflow by calling mpfr_pow_z, so that calling + mpfr_pow_z directly should be a bit more efficient. */ + + MPFR_ZIV_FREE (loop); + mpfr_clear (res); + for (size_k = 0, m = k; m != 0; size_k++, m >>= 1) + ; + mpfr_init2 (kf, size_k); + inexact = mpfr_set_ui (kf, k, MPFR_RNDN); + MPFR_ASSERTD (inexact == 0); + mpz_init (z); + mpz_set_ui (z, n); + MPFR_BLOCK (flags, inexact = mpfr_pow_z (x, kf, z, rnd);); + mpz_clear (z); + mpfr_clear (kf); + MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, flags); + goto end; + } + /* since the loop is executed floor(log2(n)) times, we have err = 1+floor(log2(n)). Since prec >= MPFR_PREC(x) + 4 + floor(log2(n)), prec > err */ err = prec - err; - if (MPFR_LIKELY (inexact == 0 + MPFR_LOG_VAR (res); + if (MPFR_LIKELY (!inex_res || MPFR_CAN_ROUND (res, err, MPFR_PREC (x), rnd))) break; @@ -90,6 +128,7 @@ mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int y, unsigned long int n, mpfr_clear (res); + end: MPFR_SAVE_EXPO_FREE (expo); return mpfr_check_range (x, inexact, rnd); } diff --git a/Build/source/libs/mpfr/mpfr-src/src/ui_sub.c b/Build/source/libs/mpfr/mpfr-src/src/ui_sub.c index 512eb8a6756..06b7db27b38 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/ui_sub.c +++ b/Build/source/libs/mpfr/mpfr-src/src/ui_sub.c @@ -27,9 +27,9 @@ int mpfr_ui_sub (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mpfr_rnd_t rnd_mode) { MPFR_LOG_FUNC - (("u=%lu x[%Pu]=%.*Rg rnd=%d", + (("u=%lu x[%Pd]=%.*Rg rnd=%d", u, mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode), - ("y[%Pu]=%.*Rg", mpfr_get_prec(y), mpfr_log_prec, y)); + ("y[%Pd]=%.*Rg", mpfr_get_prec(y), mpfr_log_prec, y)); /* (unsigned long) 0 is assumed to be a real 0 (unsigned) */ if (MPFR_UNLIKELY (u == 0)) diff --git a/Build/source/libs/mpfr/mpfr-src/src/vasprintf.c b/Build/source/libs/mpfr/mpfr-src/src/vasprintf.c index 50282c857b3..b9105446cf1 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/vasprintf.c +++ b/Build/source/libs/mpfr/mpfr-src/src/vasprintf.c @@ -880,7 +880,7 @@ struct number_parts enum pad_t pad_type; /* Padding type */ mpfr_intmax_t pad_size; /* Number of padding characters */ - char sign; /* Sign character */ + char sign; /* Sign character ('-', '+', ' ', or '\0') */ char *prefix_ptr; /* Pointer to prefix part */ size_t prefix_size; /* Number of characters in *prefix_ptr */ @@ -1067,12 +1067,6 @@ regular_ab (struct number_parts *np, mpfr_srcptr p, uppercase = spec.spec == 'A'; - /* sign */ - if (MPFR_IS_NEG (p)) - np->sign = '-'; - else if (spec.showsign || spec.space) - np->sign = spec.showsign ? '+' : ' '; - if (spec.spec == 'a' || spec.spec == 'A') /* prefix part */ { @@ -1290,12 +1284,6 @@ regular_eg (struct number_parts *np, mpfr_srcptr p, const int uppercase = spec.spec == 'E' || spec.spec == 'G'; - /* sign */ - if (MPFR_IS_NEG (p)) - np->sign = '-'; - else if (spec.showsign || spec.space) - np->sign = spec.showsign ? '+' : ' '; - /* integral part */ np->ip_size = 1; if (dec_info == NULL) @@ -1425,12 +1413,6 @@ regular_fg (struct number_parts *np, mpfr_srcptr p, and it should have been changed to 6 before the function call) */ MPFR_ASSERTD (spec.prec >= 0); - /* sign */ - if (MPFR_IS_NEG (p)) - np->sign = '-'; - else if (spec.showsign || spec.space) - np->sign = spec.showsign ? '+' : ' '; - if (MPFR_GET_EXP (p) <= 0) /* 0 < |p| < 1 */ { @@ -1725,8 +1707,7 @@ partition_number (struct number_parts *np, mpfr_srcptr p, /* WARNING: left justification means right space padding */ np->pad_type = spec.left ? RIGHT : spec.pad == '0' ? LEADING_ZEROS : LEFT; np->pad_size = 0; - np->sign = '\0'; - np->prefix_ptr =NULL; + np->prefix_ptr = NULL; np->prefix_size = 0; np->thousands_sep = '\0'; np->ip_ptr = NULL; @@ -1746,6 +1727,12 @@ partition_number (struct number_parts *np, mpfr_srcptr p, uppercase = spec.spec == 'A' || spec.spec == 'E' || spec.spec == 'F' || spec.spec == 'G'; + /* The sign/space rule is the same for all cases. */ + np->sign = + MPFR_IS_NEG (p) ? '-' : + spec.showsign ? '+' : + spec.space ? ' ' : '\0'; + if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (p))) { if (MPFR_IS_NAN (p)) @@ -1767,9 +1754,6 @@ partition_number (struct number_parts *np, mpfr_srcptr p, with left spaces instead */ np->pad_type = LEFT; - if (MPFR_IS_NEG (p)) - np->sign = '-'; - np->ip_size = MPFR_INF_STRING_LENGTH; str = (char *) mpfr_allocate_func (1 + np->ip_size); strcpy (str, uppercase ? MPFR_INF_STRING_UC : MPFR_INF_STRING_LC); @@ -1781,11 +1765,6 @@ partition_number (struct number_parts *np, mpfr_srcptr p, /* note: for 'g' spec, zero is always displayed with 'f'-style with precision spec.prec - 1 and the trailing zeros are removed unless the flag '#' is used. */ - if (MPFR_IS_NEG (p)) - /* signed zero */ - np->sign = '-'; - else if (spec.showsign || spec.space) - np->sign = spec.showsign ? '+' : ' '; if (spec.spec == 'a' || spec.spec == 'A') /* prefix part */ @@ -1849,9 +1828,6 @@ partition_number (struct number_parts *np, mpfr_srcptr p, /* change to right justification padding with left spaces */ np->pad_type = LEFT; - if (MPFR_IS_NEG (p)) - np->sign = '-'; - np->ip_size = 3; str = (char *) mpfr_allocate_func (1 + np->ip_size); strcpy (str, uppercase ? "UBF" : "ubf"); @@ -1888,7 +1864,7 @@ partition_number (struct number_parts *np, mpfr_srcptr p, precision T-1. where T is the threshold computed below and X is the exponent that would be displayed with style 'e' and precision T-1. */ - int threshold; + mpfr_intmax_t threshold; mpfr_exp_t x, e, k; struct decimal_info dec_info; @@ -1920,9 +1896,15 @@ partition_number (struct number_parts *np, mpfr_srcptr p, e = e <= 0 ? k : (e + 2) / 3 + (k <= 0 ? 0 : k); MPFR_ASSERTD (e >= 1); + if (e > threshold) + e = threshold; + + /* error if e does not fit in size_t (for mpfr_get_str) */ + if (e > (size_t) -1) + goto error; + dec_info.str = mpfr_get_str (NULL, &dec_info.exp, 10, - e < threshold ? e : threshold, - p, spec.rnd_mode); + e, p, spec.rnd_mode); register_string (np->sl, dec_info.str); /* mpfr_get_str corresponds to a significand between 0.1 and 1, whereas here we want a significand between 1 and 10. */ @@ -2030,7 +2012,7 @@ sprnt_fp (struct string_buffer *buf, mpfr_srcptr p, if (np.pad_type == LEFT && np.pad_size != 0) buffer_pad (buf, ' ', np.pad_size); - /* sign character (may be '-', '+', or ' ') */ + /* sign character (may be '-', '+', ' ', or '\0') */ if (np.sign) buffer_pad (buf, np.sign, 1); diff --git a/Build/source/libs/mpfr/mpfr-src/src/version.c b/Build/source/libs/mpfr/mpfr-src/src/version.c index 25d88f71839..d0575324ca6 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/version.c +++ b/Build/source/libs/mpfr/mpfr-src/src/version.c @@ -25,5 +25,5 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., const char * mpfr_get_version (void) { - return "4.2.0"; + return "4.2.1"; } diff --git a/Build/source/libs/mpfr/mpfr-src/src/yn.c b/Build/source/libs/mpfr/mpfr-src/src/yn.c index c4d48668107..e33b3a8c5a4 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/yn.c +++ b/Build/source/libs/mpfr/mpfr-src/src/yn.c @@ -154,8 +154,8 @@ mpfr_yn (mpfr_ptr res, long n, mpfr_srcptr z, mpfr_rnd_t r) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC - (("n=%ld x[%Pu]=%.*Rg rnd=%d", n, mpfr_get_prec (z), mpfr_log_prec, z, r), - ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (res), mpfr_log_prec, res, inex)); + (("n=%ld x[%Pd]=%.*Rg rnd=%d", n, mpfr_get_prec (z), mpfr_log_prec, z, r), + ("y[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (res), mpfr_log_prec, res, inex)); absn = SAFE_ABS (unsigned long, n); diff --git a/Build/source/libs/mpfr/mpfr-src/src/zeta.c b/Build/source/libs/mpfr/mpfr-src/src/zeta.c index 18c7e179f29..e66ff908b95 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/zeta.c +++ b/Build/source/libs/mpfr/mpfr-src/src/zeta.c @@ -447,8 +447,8 @@ mpfr_zeta (mpfr_ptr z, mpfr_srcptr s, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_DECL (expo); MPFR_LOG_FUNC ( - ("s[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (s), mpfr_log_prec, s, rnd_mode), - ("z[%Pu]=%.*Rg inexact=%d", mpfr_get_prec (z), mpfr_log_prec, z, inex)); + ("s[%Pd]=%.*Rg rnd=%d", mpfr_get_prec (s), mpfr_log_prec, s, rnd_mode), + ("z[%Pd]=%.*Rg inexact=%d", mpfr_get_prec (z), mpfr_log_prec, z, inex)); /* Zero, Nan or Inf ? */ if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (s))) diff --git a/Build/source/libs/mpfr/mpfr-src/src/zeta_ui.c b/Build/source/libs/mpfr/mpfr-src/src/zeta_ui.c index dcbb49f2d8b..a2b3b6cd026 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/zeta_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/zeta_ui.c @@ -29,8 +29,8 @@ mpfr_zeta_ui (mpfr_ptr z, unsigned long m, mpfr_rnd_t r) MPFR_ZIV_DECL (loop); MPFR_LOG_FUNC - (("m=%lu rnd=%d prec=%Pu", m, r, mpfr_get_prec (z)), - ("z[%Pu]=%.*Rg", mpfr_get_prec (z), mpfr_log_prec, z)); + (("m=%lu rnd=%d prec=%Pd", m, r, mpfr_get_prec (z)), + ("z[%Pd]=%.*Rg", mpfr_get_prec (z), mpfr_log_prec, z)); if (m == 0) /* zeta(0) = -1/2 */ return mpfr_set_si_2exp (z, -1, -1, r); |