summaryrefslogtreecommitdiff
path: root/src/set_d128.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-06-22 00:31:33 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-06-22 00:31:33 +0000
commit55af87cc4ad6ff5be7c86762c47f09d8ad3d9cb5 (patch)
tree8e3dd6a3b54b939e68cdadbb56f2adfe2c8f2503 /src/set_d128.c
parentb960578ca926698e8fc2807d7015908dc0827cb1 (diff)
downloadmpfr-55af87cc4ad6ff5be7c86762c47f09d8ad3d9cb5.tar.gz
[src/set_d128.c]
* Enable the _MPFR_IEEE_FLOATS code only for GMP_NUMB_BITS == 32 or 64 (as the other values are not supported by this code). * Bug fix for GMP_NUMB_BITS == 32 (→ tget_set_d128 no longer fails). * Added an assertion corresponding to a comment. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12809 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/set_d128.c')
-rw-r--r--src/set_d128.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/set_d128.c b/src/set_d128.c
index 1a69bbf1f..dfeaadde1 100644
--- a/src/set_d128.c
+++ b/src/set_d128.c
@@ -102,7 +102,7 @@ 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 && (GMP_NUMB_BITS == 32 || GMP_NUMB_BITS == 64)
/* Convert d to a decimal string (one-to-one correspondence, no rounding).
The string s needs to have at least 44 characters (including the final \0):
* 1 for the sign '-'
@@ -128,7 +128,7 @@ decimal128_to_string (char *s, _Decimal128 d)
int Gh; /* most 5 significant bits from combination field */
int exp; /* exponent */
mp_limb_t rp[4];
- mp_size_t rn = 2;
+ mp_size_t rn;
unsigned int i;
#ifdef DPD_FORMAT
unsigned int d0, d1, d2, d3, d4, d5;
@@ -193,7 +193,7 @@ decimal128_to_string (char *s, _Decimal128 d)
(including the bits of the trailing significand field) */
exp = x.s.comb >> 3; /* upper 14 bits, exp <= 12287 */
rp[3] = ((x.s.comb & 7) << 14) | x.s.t0;
- /* rp[3] is less than 2^17 */
+ MPFR_ASSERTD (rp[3] < MPFR_LIMB_ONE << 17); /* rp[3] < 2^17 */
}
else
{
@@ -208,6 +208,8 @@ decimal128_to_string (char *s, _Decimal128 d)
rp[0] |= rp[1] << 32;
rp[1] = rp[2] | (rp[3] << 32);
rn = 2;
+#else
+ rn = 4;
#endif
while (rn > 0 && rp[rn - 1] == 0)
rn --;