summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-09-10 19:17:57 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-09-10 19:17:57 +0000
commit79f591c2fe608c7497a87f6f4cf621c0fd8d62b0 (patch)
tree3a9bd0df194d151b9a9d6d6e1b36ab18ff86c722
parent3bf2518bb4947d0ef393b2fcb04997ea511ce7fe (diff)
downloadmpfr-79f591c2fe608c7497a87f6f4cf621c0fd8d62b0.tar.gz
[src/strtofr.c] fix from r13163 was incorrect
[tests/tget_str.c] added a testcase, and fixed an error message git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13164 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/strtofr.c6
-rw-r--r--tests/tget_str.c18
2 files changed, 23 insertions, 1 deletions
diff --git a/src/strtofr.c b/src/strtofr.c
index 5f4b80e72..703caa7b2 100644
--- a/src/strtofr.c
+++ b/src/strtofr.c
@@ -570,7 +570,11 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mpfr_rnd_t rnd)
exact = mpn_rshift (y, y, real_ysize, GMP_NUMB_BITS - count) ==
MPFR_LIMB_ZERO;
else
- exact = 1;
+ {
+ /* copy {y+1, real_ysize-1} to {y, real_ysize-1} */
+ exact = y[0] == MPFR_LIMB_ZERO;
+ mpn_copyi (y, y + 1, real_ysize - 1);
+ }
/* for each bit shift increase exponent of y */
exp = GMP_NUMB_BITS - count;
}
diff --git a/tests/tget_str.c b/tests/tget_str.c
index 2bec91201..85b417e7e 100644
--- a/tests/tget_str.c
+++ b/tests/tget_str.c
@@ -1425,6 +1425,7 @@ check_corner (void)
{
printf ("mpfr_set_str o mpfr_get_str <> Id for b=%d\n", b);
printf ("x="); mpfr_dump (x);
+ t[oprec] = '\0';
printf ("mpfr_get_str converted to 0.%s@%ld\n", t, (long) f);
printf ("mpfr_set_str converted to:\n");
printf ("y="); mpfr_dump (y);
@@ -1437,6 +1438,22 @@ check_corner (void)
}
}
+static void
+bug20180908 (void)
+{
+ mpfr_t x, y;
+ const char s[] = "ssq4";
+
+ mpfr_init2 (x, 12);
+ mpfr_init2 (y, 12);
+ mpfr_set_str_binary (x, "0.100010111010E24");
+ /* x = 9150464 = [4, 52, 54, 54] in base 55 */
+ mpfr_set_str (y, s, 55, MPFR_RNDN);
+ MPFR_ASSERTN (mpfr_equal_p (x, y));
+ mpfr_clear (x);
+ mpfr_clear (y);
+}
+
int
main (int argc, char *argv[])
{
@@ -1451,6 +1468,7 @@ main (int argc, char *argv[])
tests_start_mpfr ();
+ bug20180908 ();
check_corner ();
test_ndigits ();
coverage ();