summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-09-11 07:39:16 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2018-09-11 07:39:16 +0000
commit7fc5ba57421ec12357add79068260896e38b1817 (patch)
tree9f96429397eafd96bada4589dc07711260a42347
parent6078e34c03879dc05805c249e804b3e50e79db34 (diff)
downloadmpfr-7fc5ba57421ec12357add79068260896e38b1817.tar.gz
[src/strtofr.c] added comment
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13166 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/strtofr.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/strtofr.c b/src/strtofr.c
index 703caa7b2..9ac116341 100644
--- a/src/strtofr.c
+++ b/src/strtofr.c
@@ -512,6 +512,17 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mpfr_rnd_t rnd)
and ysize_bits = a*Den+b,
then ysize_bits * Num/Den = a*Num + (b * Num)/Den,
thus ceil(ysize_bits * Num/Den) = a*Num + floor(b * Num + Den - 1)/Den
+
+ Note: denoting m = pstr_size and n = ysize_bits, assuming we have
+ m = 1 + ceil(n/log2(b)), i.e., b^(m-1) >= 2^n > b^(m-2), then
+ b^(m-1)/2^n < b, and since we consider m characters of the input,
+ the corresponding part is less than b^m < b^2*2^n.
+ This implies that if b^2 < 2^GMP_NUMB_BITS, which for b <= 62 holds
+ for GMP_NUMB_BITS >= 12, we have real_ysize <= ysize+1 below
+ (this also imlies that for GMP_NUMB_BITS >= 13, the number of bits
+ of y[real_ysize-1] below is less than GMP_NUMB_BITS, thus
+ count < GMP_NUMB_BITS.
+ Warning: for GMP_NUMB_BITS=8, we can have real_ysize = ysize+2!
*/
{
unsigned long Num = RedInvLog2Table[pstr->base-2][0];