summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2020-04-10 11:19:19 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2020-04-10 11:19:19 +0000
commit1ac2b1ca55ea54a7045c42c532f494b9f7e9bf24 (patch)
tree38c1ae86241cfcbf86fe47a3c8a58d23d4ad4470
parent9035cc7a9e134d55cf153464d2d8a8bf2f563b67 (diff)
downloadmpfr-1ac2b1ca55ea54a7045c42c532f494b9f7e9bf24.tar.gz
Reworked decimal support and detection, resolving FIXMEs.
* INSTALL, acinclude.m4, configure.ac: --enable-decimal-float can take new values. Change of macro DPD_FORMAT (DPD was assumed in case of cross-compilation, which could be wrong) to 3 new macros: DECIMAL_DPD_FORMAT, DECIMAL_BID_FORMAT, DECIMAL_GENERIC_CODE. * doc/README.dev: documented these 3 new macros. * src/mpfr-impl.h: the detection of the BID encoding can now be done at compile time when GCC defines __DECIMAL_BID_FORMAT__ (as on x86); support of the 3 new macros. * src/{get_d64.c,set_d64.c,set_d128.c}: update. * tests/{tget_set_d64.c,tget_set_d128.c,tversion.c}: update. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13878 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--INSTALL21
-rw-r--r--acinclude.m486
-rw-r--r--configure.ac7
-rw-r--r--doc/README.dev8
-rw-r--r--src/get_d64.c25
-rw-r--r--src/mpfr-impl.h49
-rw-r--r--src/set_d128.c17
-rw-r--r--src/set_d64.c22
-rw-r--r--tests/tget_set_d128.c12
-rw-r--r--tests/tget_set_d64.c12
-rw-r--r--tests/tversion.c12
11 files changed, 189 insertions, 82 deletions
diff --git a/INSTALL b/INSTALL
index 0eb28f091..f1b6a5ccc 100644
--- a/INSTALL
+++ b/INSTALL
@@ -224,6 +224,27 @@ specific architecture.
buggy (MPFR tests may fail). In such a case,
this option is useful.
+--enable-decimal-float build conversion functions from/to decimal floats.
+ Note that detection by the configure script is
+ limited in case of cross-compilation.
+ Accepted arguments:
+ yes Decimal support is requested and the configure
+ script fails if it detects that decimals do not
+ work.
+ The encoding (BID or DPD) will automatically be
+ detected at configure time or at compile time if
+ possible (if not, generic code will be used).
+ no Decimal support is explicitly disabled.
+ auto Decimal support is enabled if the configure script
+ detects that it works. This is the default when
+ --{enable,disable}-decimal-float is not given.
+ bid Decimal support is requested and the encoding is
+ assumed to be BID (some check may be done).
+ dpd Decimal support is requested and the encoding is
+ assumed to be DPD (some check may be done).
+ generic Decimal support is requested and the generic code
+ is used (mainly for developers).
+
--enable-gmp-internals allows the MPFR build to use GMP's undocumented
functions (not from the public API). Note that
library versioning is not guaranteed to work if
diff --git a/acinclude.m4 b/acinclude.m4
index ab58c129a..b1010a470 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -648,15 +648,6 @@ dnl 3. Use uint64_t (or unsigned long long, though this type might not be
dnl on 64 bits) instead of or in addition to the test on double.
dnl 4. Use an array of 8 unsigned char's instead of or in addition to the
dnl test on double, considering the 2 practical cases of endianness.
-dnl FIXME: In case of cross-compiling, the guess "DPD" can be wrong, e.g.
-dnl for the build with MinGW under Linux. There should be a way to choose
-dnl between BID, DPD and unknown, and in the latter case, select the
-dnl portable implementation of the decimal functions. Currently, the
-dnl portable implementation is selected just because of the ugliness of
-dnl the MPFR code, which depends on the binary formats (!!!) and because
-dnl the check of the "double" format also uses AC_RUN_IFELSE (contrary to
-dnl the "long double" test), thus the "double" format is unknown, and only
-dnl the portable implementation can be used.
if test "$enable_decimal_float" != no; then
AC_MSG_CHECKING(if compiler knows _Decimal64)
AC_COMPILE_IFELSE(
@@ -677,33 +668,64 @@ return y.d == 0.14894469406741037E-123 ? 80 :
[d64_exit_status=$?
case "$d64_exit_status" in
80) AC_MSG_RESULT(DPD)
- AC_DEFINE([DPD_FORMAT],1,[DPD format])
- AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1,
- [Build decimal float functions]) ;;
- 81) AC_MSG_RESULT(BID)
- AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1,
- [Build decimal float functions]) ;;
- 82) AC_MSG_RESULT(neither DPD nor BID)
- if test "$enable_decimal_float" = yes; then
- AC_MSG_ERROR([unsupported decimal float format.
-Please build MPFR without --enable-decimal-float.])
+ if test "$enable_decimal_float" = bid; then
+ AC_MSG_ERROR([encoding mismatch (BID requested).])
+ fi
+ if test "$enable_decimal_float" != generic; then
+ enable_decimal_float=dpd
fi ;;
- *) AC_MSG_RESULT(unknown (exit status $d64_exit_status))
- if test "$enable_decimal_float" = yes; then
- AC_MSG_ERROR([internal or link error.
-Please build MPFR without --enable-decimal-float.])
+ 81) AC_MSG_RESULT(BID)
+ if test "$enable_decimal_float" = dpd; then
+ AC_MSG_ERROR([encoding mismatch (DPD requested).])
+ fi
+ if test "$enable_decimal_float" != generic; then
+ enable_decimal_float=bid
fi ;;
+ 82) AC_MSG_RESULT(neither DPD nor BID)
+ if test "$enable_decimal_float" = dpd; then
+ AC_MSG_ERROR([encoding mismatch (DPD requested).])
+ fi
+ if test "$enable_decimal_float" = bid; then
+ AC_MSG_ERROR([encoding mismatch (BID requested).])
+ fi
+ enable_decimal_float=generic
+ AC_MSG_WARN([The _Decimal64 encoding is non-standard or there was an])
+ AC_MSG_WARN([issue with its detection. The generic code will be used.])
+ AC_MSG_WARN([Please do not forget to test with `make check'.])
+ AC_MSG_WARN([In case of failure of a decimal test, you should rebuild])
+ AC_MSG_WARN([MPFR without --enable-decimal-float.]) ;;
+ *) AC_MSG_RESULT(error (exit status $d64_exit_status))
+ case "$enable_decimal_float" in
+ yes|bid|dpd|generic) AC_MSG_FAILURE([internal or link error.
+Please build MPFR without --enable-decimal-float.]) ;;
+ *) enable_decimal_float=no ;;
+ esac ;;
esac],
- [AC_MSG_RESULT(assuming DPD)
- AC_DEFINE([DPD_FORMAT],1,[])
- AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1,
- [Build decimal float functions])])
- ],
+ [AC_MSG_RESULT(cannot test)
+ dnl Since the _Decimal64 type exists, we assume that it is correctly
+ dnl supported. The detection of the encoding may still be done at
+ dnl compile time. We do not add a configure test for it so that this
+ dnl can be done on platforms where configure cannot be used.
+ enable_decimal_float=compile-time])
+ ],
[AC_MSG_RESULT(no)
- if test "$enable_decimal_float" = yes; then
- AC_MSG_ERROR([compiler doesn't know _Decimal64 (ISO/IEC TR 24732).
-Please use another compiler or build MPFR without --enable-decimal-float.])
- fi])
+ case "$enable_decimal_float" in
+ yes|bid|dpd|generic)
+ AC_MSG_FAILURE([compiler doesn't know _Decimal64 (ISO/IEC TR 24732).
+Please use another compiler or build MPFR without --enable-decimal-float.]) ;;
+ *) enable_decimal_float=no ;;
+ esac])
+ if test "$enable_decimal_float" != no; then
+ AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1,
+ [Build decimal float functions])
+ case "$enable_decimal_float" in
+ dpd) AC_DEFINE([DECIMAL_DPD_FORMAT],1,[]) ;;
+ bid) AC_DEFINE([DECIMAL_BID_FORMAT],1,[]) ;;
+ generic) AC_DEFINE([DECIMAL_GENERIC_CODE],1,[]) ;;
+ compile-time) ;;
+ *) AC_MSG_ERROR(internal error) ;;
+ esac
+ fi
fi
dnl Check the bit-field ordering for _Decimal128.
diff --git a/configure.ac b/configure.ac
index ac9caa66e..87f18f923 100644
--- a/configure.ac
+++ b/configure.ac
@@ -236,11 +236,10 @@ dnl --disable-decimal-float would explicitly disable both.
AC_ARG_ENABLE(decimal-float,
[ --disable-decimal-float explicitly disable decimal floats support
--enable-decimal-float build conversion functions from/to decimal floats
- [[default=autodetect]]],
+ (see INSTALL file for details) [[default=auto]]],
[ case $enableval in
- yes) ;;
- no) ;;
- *) AC_MSG_ERROR([bad value for --enable-decimal-float: yes or no]) ;;
+ yes|no|auto|bid|dpd|generic) ;;
+ *) AC_MSG_ERROR([bad value for --enable-decimal-float]) ;;
esac])
dnl Warning! Not to be confused with _Decimal128. Thus it is better
diff --git a/doc/README.dev b/doc/README.dev
index 3e80b19c1..3afe271cf 100644
--- a/doc/README.dev
+++ b/doc/README.dev
@@ -475,9 +475,15 @@ Format of long double.
as double-double (a.k.a. IBM long double).
+ MPFR_USE_LOGGING: Define to enable logging.
+
+ MPFR_WANT_DECIMAL_FLOATS:
Define to build conversion functions from/to
- decimal floats.
+ decimal floats. At most one of the following
+ three macros can be defined.
++ DECIMAL_BID_FORMAT: BID encoding detected or assumed.
++ DECIMAL_DPD_FORMAT: DPD encoding detected or assumed.
++ DECIMAL_GENERIC_CODE: Use generic code for decimal floats.
+
+ MPFR_WANT_FLOAT128: Define to build conversion functions from/to
binary128 floats (_Float128 or __float128).
diff --git a/src/get_d64.c b/src/get_d64.c
index 4d08a781d..2f030314f 100644
--- a/src/get_d64.c
+++ b/src/get_d64.c
@@ -31,8 +31,7 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#ifdef MPFR_WANT_DECIMAL_FLOATS
-#if _MPFR_IEEE_FLOATS
-#else
+#if ! _MPFR_IEEE_FLOATS
#include "ieee_floats.h"
#endif
@@ -40,7 +39,7 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
# define DEC64_MAX 9.999999999999999E384dd
#endif
-#ifdef DPD_FORMAT
+#ifdef DECIMAL_DPD_FORMAT
static const int T[1000] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
@@ -181,7 +180,9 @@ get_decimal64_max (int negative)
Assumes s is neither NaN nor +Inf nor -Inf.
s = [-][0-9]+E[-][0-9]+
*/
-#if _MPFR_IEEE_FLOATS
+
+#if _MPFR_IEEE_FLOATS && !defined(DECIMAL_GENERIC_CODE)
+
static _Decimal64
string_to_Decimal64 (char *s)
{
@@ -191,7 +192,7 @@ string_to_Decimal64 (char *s)
char *endptr[1];
union mpfr_ieee_double_extract x;
union ieee_double_decimal64 y;
-#ifdef DPD_FORMAT
+#ifdef DECIMAL_DPD_FORMAT
unsigned int G, d1, d2, d3, d4, d5;
#endif
@@ -247,7 +248,7 @@ string_to_Decimal64 (char *s)
}
/* now convert to DPD or BID */
-#ifdef DPD_FORMAT
+#ifdef DECIMAL_DPD_FORMAT
#define CH(d) (d - '0')
if (m[0] >= '8')
G = (3 << 11) | ((exp & 768) << 1) | ((CH(m[0]) & 1) << 8);
@@ -264,7 +265,7 @@ string_to_Decimal64 (char *s)
x.s.manh = ((G & 3) << 18) | (d1 << 8) | (d2 >> 2);
x.s.manl = (d2 & 3) << 30;
x.s.manl |= (d3 << 20) | (d4 << 10) | d5;
-#else /* BID format */
+#else /* BID */
{
unsigned int rp[2]; /* rp[0] and rp[1] should contain at least 32 bits */
#define NLIMBS (64 / GMP_NUMB_BITS)
@@ -311,12 +312,13 @@ string_to_Decimal64 (char *s)
x.s.manh = (rp[1] ^ 2097152) | ((exp & 1) << 19);
}
}
-#endif /* DPD_FORMAT */
+#endif /* DPD or BID */
y.d = x.d;
return y.d64;
}
-#else
-/* portable version */
+
+#else /* portable version */
+
static _Decimal64
string_to_Decimal64 (char *s)
{
@@ -498,7 +500,8 @@ string_to_Decimal64 (char *s)
return x;
}
-#endif
+
+#endif /* definition of string_to_Decimal64 (DPD, BID, or portable) */
_Decimal64
mpfr_get_decimal64 (mpfr_srcptr src, mpfr_rnd_t rnd_mode)
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h
index b190ec171..59feaa42a 100644
--- a/src/mpfr-impl.h
+++ b/src/mpfr-impl.h
@@ -828,6 +828,55 @@ typedef union {
#ifdef MPFR_WANT_DECIMAL_FLOATS
+#if defined(__GNUC__) && \
+ __FLT64_DECIMAL_DIG__ == 17 && \
+ __FLT128_DECIMAL_DIG__ == 36
+
+/* GCC has standard _Decimal64 and _Decimal128 support.
+ We may be able to detect the encoding here at compile time.
+
+ Note: GCC may define __FLT64_DECIMAL_DIG__ and __FLT128_DECIMAL_DIG__
+ even when it does not support _Decimal64 and _Decimal128, e.g. on
+ aarch64 and sparc64. But since MPFR_WANT_DECIMAL_FLOATS has been
+ defined, we already know that these types should be supported.
+
+ Determining which encoding is used via macros is not documented, and
+ there is the risk of being wrong. Currently __DECIMAL_BID_FORMAT__ is
+ defined on x86, where the BID encoding is used. But on PowerPC, where
+ the DPD encoding is used, nothing indicating the encoding is defined.
+ A possible reason may be that the decimal support is provided by the
+ hardware (in this case), so that GCC does not need to care about the
+ encoding. Thus the absence of a __DECIMAL_BID_FORMAT__ macro would
+ not necessarily imply DPD, as similarly in the future, GCC could
+ support an ISA-level implementation using the BID encoding. */
+
+#ifdef __DECIMAL_BID_FORMAT__
+
+#if defined(DECIMAL_DPD_FORMAT)
+# error "Decimal encoding mismatch (DPD assumed, BID detected)"
+#elif !defined(DECIMAL_GENERIC_CODE)
+# define DECIMAL_BID_FORMAT 1
+#endif
+
+#endif /* __DECIMAL_BID_FORMAT__ */
+
+#endif /* __GNUC__ */
+
+#if defined(DECIMAL_GENERIC_CODE)
+# if defined(DECIMAL_BID_FORMAT)
+# error "DECIMAL_BID_FORMAT and DECIMAL_GENERIC_CODE both defined"
+# endif
+# if defined(DECIMAL_DPD_FORMAT)
+# error "DECIMAL_DPD_FORMAT and DECIMAL_GENERIC_CODE both defined"
+# endif
+#elif defined(DECIMAL_BID_FORMAT) || defined(DECIMAL_DPD_FORMAT)
+# if defined(DECIMAL_BID_FORMAT) && defined(DECIMAL_DPD_FORMAT)
+# error "DECIMAL_BID_FORMAT and DECIMAL_DPD_FORMAT both defined"
+# endif
+#else
+# define DECIMAL_GENERIC_CODE 1
+#endif
+
/* TODO: The following is ugly and possibly wrong on some platforms.
Do something like union ieee_decimal128. */
union ieee_double_decimal64 { double d; _Decimal64 d64; };
diff --git a/src/set_d128.c b/src/set_d128.c
index 9d2d904c2..abee67095 100644
--- a/src/set_d128.c
+++ b/src/set_d128.c
@@ -30,9 +30,11 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#ifdef MPFR_WANT_DECIMAL_FLOATS
-#if HAVE_DECIMAL128_IEEE && (GMP_NUMB_BITS == 32 || GMP_NUMB_BITS == 64)
+#if HAVE_DECIMAL128_IEEE && \
+ (GMP_NUMB_BITS == 32 || GMP_NUMB_BITS == 64) && \
+ !defined(DECIMAL_GENERIC_CODE)
-#ifdef DPD_FORMAT
+#ifdef DECIMAL_DPD_FORMAT
/* conversion 10-bits to 3 digits */
static unsigned int T[1024] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 80, 81, 800, 801, 880, 881, 10, 11, 12, 13,
@@ -129,9 +131,9 @@ decimal128_to_string (char *s, _Decimal128 d)
int Gh; /* most 5 significant bits from combination field */
int exp; /* exponent */
unsigned int i;
-#ifdef DPD_FORMAT
+#ifdef DECIMAL_DPD_FORMAT
unsigned int D[12]; /* declets */
-#else
+#else /* BID */
mp_limb_t rp[4];
mp_size_t rn;
#endif
@@ -163,7 +165,7 @@ decimal128_to_string (char *s, _Decimal128 d)
12 remaining bits)
* a trailing significand field of 110 bits
*/
-#ifdef DPD_FORMAT
+#ifdef DECIMAL_DPD_FORMAT
/* page 11 of IEEE 754-2008, case c1) */
if (Gh < 24)
{
@@ -246,8 +248,7 @@ decimal128_to_string (char *s, _Decimal128 d)
sprintf (t, "E%d", exp);
}
-#else
-/* portable version */
+#else /* portable version */
#ifndef DEC128_MAX
# define DEC128_MAX 9.999999999999999999999999999999999E6144dl
@@ -472,7 +473,7 @@ decimal128_to_string (char *s, _Decimal128 d)
*s = '\0';
}
-#endif /* _MPFR_IEEE_FLOATS */
+#endif /* definition of decimal128_to_string (DPD, BID, or portable) */
/* the IEEE754-2008 decimal128 format has 34 digits, with emax=6144,
emin=1-emax=-6143 */
diff --git a/src/set_d64.c b/src/set_d64.c
index a2012728f..41c2e7da5 100644
--- a/src/set_d64.c
+++ b/src/set_d64.c
@@ -30,7 +30,7 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#ifdef MPFR_WANT_DECIMAL_FLOATS
-#ifdef DPD_FORMAT
+#ifdef DECIMAL_DPD_FORMAT
/* conversion 10-bits to 3 digits */
static unsigned int T[1024] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 80, 81, 800, 801, 880, 881, 10, 11, 12, 13,
@@ -102,7 +102,8 @@ static unsigned int T[1024] = {
774, 775, 776, 777, 778, 779, 796, 797, 976, 977, 998, 999 };
#endif
-#if _MPFR_IEEE_FLOATS
+#if _MPFR_IEEE_FLOATS && !defined(DECIMAL_GENERIC_CODE)
+
/* Convert d to a decimal string (one-to-one correspondence, no rounding).
The string s needs to have at least 25 characters (with the final '\0'):
* 1 for the sign '-'
@@ -120,9 +121,10 @@ decimal64_to_string (char *s, _Decimal64 d)
unsigned int Gh; /* most 5 significant bits from combination field */
int exp; /* exponent */
unsigned int i;
-#ifdef DPD_FORMAT
+
+#ifdef DECIMAL_DPD_FORMAT
unsigned int d0, d1, d2, d3, d4, d5;
-#else
+#else /* BID */
#if GMP_NUMB_BITS >= 64
mp_limb_t rp[2];
#else
@@ -133,6 +135,8 @@ decimal64_to_string (char *s, _Decimal64 d)
mp_size_t sn;
#endif
+ /* end of declarations */
+
/* Memory representation of the _Decimal64 argument. */
MPFR_LOG_MSG (("d = { %02X, %02X, %02X, %02X, %02X, %02X, %02X, %02X }\n",
((unsigned char *) &d)[0],
@@ -175,7 +179,7 @@ decimal64_to_string (char *s, _Decimal64 d)
* a combination field of 13=5+8 bits
* a trailing significand field of 50 bits
*/
-#ifdef DPD_FORMAT
+#ifdef DECIMAL_DPD_FORMAT
/* the most significant 5 bits of the combination field give the first digit
of the significand, and leading bits of the biased exponent (0, 1, 2). */
if (Gh < 24)
@@ -270,8 +274,9 @@ decimal64_to_string (char *s, _Decimal64 d)
emin = 1-emax = 1-384 = -383 and p=16 */
sprintf (t, "E%d", exp);
}
-#else
-/* portable version */
+
+#else /* portable version */
+
#ifndef DEC64_MAX
# define DEC64_MAX 9.999999999999999E384dd
#endif
@@ -469,7 +474,8 @@ decimal64_to_string (char *s, _Decimal64 d)
else
*s = '\0';
}
-#endif /* _MPFR_IEEE_FLOATS */
+
+#endif /* definition of decimal64_to_string (DPD, BID, or portable) */
/* the IEEE754-2008 decimal64 format has 16 digits, with emax=384,
emin=1-emax=-383 */
diff --git a/tests/tget_set_d128.c b/tests/tget_set_d128.c
index e35aea69e..6d6b8581f 100644
--- a/tests/tget_set_d128.c
+++ b/tests/tget_set_d128.c
@@ -452,7 +452,7 @@ static void
noncanonical (void)
{
/* The code below assumes BID. */
-#if HAVE_DECIMAL128_IEEE && !defined(DPD_FORMAT)
+#if HAVE_DECIMAL128_IEEE && defined(DECIMAL_BID_FORMAT)
union ieee_decimal128 x;
MPFR_ASSERTN (sizeof (x) == 16);
@@ -562,11 +562,11 @@ main (int argc, char *argv[])
if (verbose)
{
-#ifdef DPD_FORMAT
- /* FIXME: DPD_FORMAT is also used when the format is unknown. */
- printf ("Using DPD format (or unknown)\n");
-#else
- printf ("Using BID format\n");
+#ifdef DECIMAL_DPD_FORMAT
+ printf ("Using DPD encoding\n");
+#endif
+#ifdef DECIMAL_BID_FORMAT
+ printf ("Using BID encoding\n");
#endif
}
diff --git a/tests/tget_set_d64.c b/tests/tget_set_d64.c
index 359378885..0ae71caf6 100644
--- a/tests/tget_set_d64.c
+++ b/tests/tget_set_d64.c
@@ -483,7 +483,7 @@ static void
noncanonical (void)
{
/* The code below assumes BID. */
-#ifndef DPD_FORMAT
+#ifdef DECIMAL_BID_FORMAT
/* The volatile below avoids _Decimal64 constant propagation, which is
buggy for non-canonical encoding in various GCC versions on the x86 and
x86_64 targets: failure with gcc (Debian 20190719-1) 10.0.0 20190718
@@ -572,11 +572,11 @@ main (int argc, char *argv[])
if (verbose)
{
-#ifdef DPD_FORMAT
- /* FIXME: DPD_FORMAT is also used when the format is unknown. */
- printf ("Using DPD format (or unknown)\n");
-#else
- printf ("Using BID format\n");
+#ifdef DECIMAL_DPD_FORMAT
+ printf ("Using DPD encoding\n");
+#endif
+#ifdef DECIMAL_BID_FORMAT
+ printf ("Using BID encoding\n");
#endif
}
diff --git a/tests/tversion.c b/tests/tversion.c
index 0d903c82e..dc9fb3af3 100644
--- a/tests/tversion.c
+++ b/tests/tversion.c
@@ -311,13 +311,13 @@ main (void)
" GMP internals = %s\n",
mpfr_buildopt_tls_p () ? "yes" : "no",
mpfr_buildopt_float128_p () ? "yes" : "no",
- mpfr_buildopt_decimal_p () ? "yes ("
-#ifdef DPD_FORMAT
- "DPD"
-#else
- "BID"
+ mpfr_buildopt_decimal_p () ? "yes"
+#if defined(DECIMAL_BID_FORMAT)
+ " (BID)"
+#elif defined(DECIMAL_DPD_FORMAT)
+ " (DPD)"
#endif
- ")" : "no",
+ : "no",
mpfr_buildopt_gmpinternals_p () ? "yes" : "no");
#ifdef MPFR_THREAD_LOCK_METHOD