summaryrefslogtreecommitdiff
path: root/src/get_str.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-23 17:02:14 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-23 17:02:14 +0000
commit1d6fff310b2d8757cbb3f2112ffb001dd6258e84 (patch)
tree1cce956cd44f627b461de0121461778d33e9dd3f /src/get_str.c
parente3ef937ed088a121662f8cc4d9c8632a45416aaf (diff)
downloadmpfr-1d6fff310b2d8757cbb3f2112ffb001dd6258e84.tar.gz
[doc/mpfr.texi] m=1 is now valid in get_str
[src/get_str.c] allow m=1 for b=2^k [tests/tget_str.c] added test for m=1 and b=2 git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12432 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/get_str.c')
-rw-r--r--src/get_str.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/get_str.c b/src/get_str.c
index 442ac7166..c06d2d147 100644
--- a/src/get_str.c
+++ b/src/get_str.c
@@ -2325,15 +2325,12 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x,
*/
m = 1 +
mpfr_ceil_mul (IS_POW2(b) ? MPFR_PREC(x) - 1 : MPFR_PREC(x), b, 1);
- if (m < 2)
- m = 2;
}
MPFR_LOG_MSG (("m=%zu\n", m));
- /* The code below for non-power-of-two bases works for m=1;
- this is important for the internal use of mpfr_get_str. */
- MPFR_ASSERTN (m >= 2 || (!IS_POW2(b) && m >= 1));
+ /* The code below works for m=1, both for power-of-two and non-power-of-two
+ bases; this is important for the internal use of mpfr_get_str. */
/* x is a floating-point number */
@@ -2376,6 +2373,8 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x,
/* the first digit will contain only r bits */
prec = (m - 1) * pow2 + r; /* total number of bits */
+ /* if m=1 then 1 <= prec <= pow2, and since prec=1 is now valid in MPFR,
+ the power-of-two code also works for m=1 */
n = MPFR_PREC2LIMBS (prec);
MPFR_TMP_MARK (marker);