1 /* mpfr_get_str -- output a floating-point number to a string
3 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by the Arenaire and Cacao projects, INRIA.
5 Contributed by Alain Delplanque and Paul Zimmermann.
7 This file is part of the GNU MPFR Library.
9 The GNU MPFR Library is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or (at your
12 option) any later version.
14 The GNU MPFR Library is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with the GNU MPFR Library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
22 MA 02110-1301, USA. */
24 #define MPFR_NEED_LONGLONG_H
25 #include "mpfr-impl.h"
27 static int mpfr_get_str_aux (char *const, mp_exp_t *const, mp_limb_t *const,
28 mp_size_t, mp_exp_t, long, int, size_t, mp_rnd_t);
30 /* The implicit \0 is useless, but we do not write num_to_text[36]
31 otherwise g++ complains. */
32 static const char num_to_text[] = "0123456789abcdefghijklmnopqrstuvwxyz";
34 /* copy most important limbs of {op, n2} in {rp, n1} */
35 /* if n1 > n2 put 0 in low limbs of {rp, n1} */
36 #define MPN_COPY2(rp, n1, op, n2) \
39 MPN_COPY ((rp), (op) + (n2) - (n1), (n1)); \
43 MPN_COPY ((rp) + (n1) - (n2), (op), (n2)); \
44 MPN_ZERO ((rp), (n1) - (n2)); \
47 #define MPFR_ROUND_FAILED 3
49 /* Input: an approximation r*2^f of a real Y, with |r*2^f-Y| <= 2^(e+f).
50 Returns if possible in the string s the mantissa corresponding to
51 the integer nearest to Y, within the direction rnd, and returns the
53 n is the number of limbs of r.
54 e represents the maximal error in the approximation of Y
55 (e < 0 iff the approximation is exact, i.e., r*2^f = Y).
56 b is the wanted base (2 <= b <= 36).
57 m is the number of wanted digits in the mantissa.
58 rnd is the rounding mode.
59 It is assumed that b^(m-1) <= Y < b^(m+1), thus the returned value
60 satisfies b^(m-1) <= rnd(Y) < b^(m+1).
62 Rounding may fail for two reasons:
63 - the error is too large to determine the integer N nearest to Y
64 - either the number of digits of N in base b is too large (m+1),
65 N=2*N1+(b/2) and the rounding mode is to nearest. This can
66 only happen when b is even.
69 - the direction of rounding (-1, 0, 1) if rounding is possible
70 - -MPFR_ROUND_FAILED if rounding not possible because m+1 digits
71 - MPFR_ROUND_FAILED otherwise (too large error)
74 mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r,
75 mp_size_t n, mp_exp_t f, long e, int b, size_t m,
78 int dir; /* direction of the rounded result */
79 mp_limb_t ret = 0; /* possible carry in addition */
80 mp_size_t i0, j0; /* number of limbs and bits of Y */
81 unsigned char *str1; /* string of m+2 characters */
82 size_t size_s1; /* length of str1 */
86 MPFR_TMP_DECL(marker);
88 /* if f > 0, then the maximal error 2^(e+f) is larger than 2 so we can't
89 determine the integer Y */
91 /* if f is too small, then r*2^f is smaller than 1 */
92 MPFR_ASSERTN(f > (-n * BITS_PER_MP_LIMB));
94 MPFR_TMP_MARK(marker);
96 /* R = 2^f sum r[i]K^(i)
97 r[i] = (r_(i,k-1)...r_(i,0))_2
98 R = sum r(i,j)2^(j+ki+f)
99 the bits from R are referenced by pairs (i,j) */
101 /* check if is possible to round r with rnd mode
102 where |r*2^f-Y| <= 2^(e+f)
103 the exponent of R is: f + n*BITS_PER_MP_LIMB
104 we must have e + f == f + n*BITS_PER_MP_LIMB - err
105 err = n*BITS_PER_MP_LIMB - e
106 R contains exactly -f bits after the integer point:
107 to determine the nearest integer, we thus need a precision of
108 n * BITS_PER_MP_LIMB + f */
110 if (exact || mpfr_can_round_raw (r, n, (mp_size_t) 1,
111 n * BITS_PER_MP_LIMB - e, GMP_RNDN, rnd, n * BITS_PER_MP_LIMB + f))
113 /* compute the nearest integer to R */
115 /* bit of weight 0 in R has position j0 in limb r[i0] */
116 i0 = (-f) / BITS_PER_MP_LIMB;
117 j0 = (-f) % BITS_PER_MP_LIMB;
119 ret = mpfr_round_raw (r + i0, r, n * BITS_PER_MP_LIMB, 0,
120 n * BITS_PER_MP_LIMB + f, rnd, &dir);
121 MPFR_ASSERTD(dir != MPFR_ROUND_FAILED);
123 /* warning: mpfr_round_raw_generic returns MPFR_EVEN_INEX (2) or
124 -MPFR_EVEN_INEX (-2) in case of even rounding */
126 if (ret) /* Y is a power of 2 */
129 r[n - 1] = MPFR_LIMB_HIGHBIT >> (j0 - 1);
130 else /* j0=0, necessarily i0 >= 1 otherwise f=0 and r is exact */
133 r[--i0] = 0; /* set to zero the new low limb */
136 else /* shift r to the right by (-f) bits (i0 already done) */
139 mpn_rshift (r + i0, r + i0, n - i0, j0);
142 /* now the rounded value Y is in {r+i0, n-i0} */
144 /* convert r+i0 into base b */
145 str1 = (unsigned char*) MPFR_TMP_ALLOC (m + 3); /* need one extra character for mpn_get_str */
146 size_s1 = mpn_get_str (str1, b, r + i0, n - i0);
149 MPFR_ASSERTN(size_s1 >= m);
150 *exp = size_s1 - m; /* number of superfluous characters */
152 /* if size_s1 = m + 2, necessarily we have b^(m+1) as result,
153 and the result will not change */
155 /* so we have to double-round only when size_s1 = m + 1 and
156 (i) the result is inexact
157 (ii) or the last digit is non-zero */
158 if ((size_s1 == m + 1) && ((dir != 0) || (str1[size_s1 - 1] != 0)))
163 /* round to nearest case */
166 if (2 * str1[size_s1 - 1] == b)
168 if (dir == 0 && exact) /* exact: even rounding */
170 rnd1 = ((str1[size_s1 - 2] & 1) == 0)
171 ? GMP_RNDD : GMP_RNDU;
175 /* otherwise we cannot round correctly: for example
176 if b=10, we might have a mantissa of
177 xxxxxxx5.00000000 which can be rounded to nearest
178 to 8 digits but not to 7 */
179 dir = -MPFR_ROUND_FAILED;
180 MPFR_ASSERTD(dir != MPFR_EVEN_INEX);
181 goto free_and_return;
184 else if (2 * str1[size_s1 - 1] < b)
190 /* now rnd1 is either GMP_RNDD or GMP_RNDZ -> truncate
191 or GMP_RDNU -> round toward infinity */
193 /* round away from zero */
194 if (rnd1 == GMP_RNDU)
196 if (str1[size_s1 - 1] != 0)
198 /* the carry cannot propagate to the whole string, since
199 Y = x*b^(m-g) < 2*b^m <= b^(m+1)-b
200 where x is the input float */
201 MPFR_ASSERTN(size_s1 >= 2);
203 while (str1[i] == b - 1)
212 /* round toward zero (truncate) */
217 /* copy str1 into str and convert to characters (digits and
218 lowercase letters from the source character set) */
219 for (i = 0; i < m; i++)
220 str[i] = num_to_text[(int) str1[i]]; /* str1[i] is an unsigned char */
223 /* mpfr_can_round_raw failed: rounding is not possible */
226 dir = MPFR_ROUND_FAILED; /* should be different from MPFR_EVEN_INEX */
227 MPFR_ASSERTD(dir != MPFR_EVEN_INEX);
231 MPFR_TMP_FREE(marker);
236 /***************************************************************************
237 * __gmpfr_l2b[b-2][0] is a 23-bit upper approximation to log(b)/log(2), *
238 * __gmpfr_l2b[b-2][1] is a 76-bit upper approximation to log(2)/log(b). *
239 * The following code is generated by tests/tl2b (with an argument). *
240 ***************************************************************************/
243 #elif BITS_PER_MP_LIMB == 16
244 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x0000, 0x8000 };
245 #elif BITS_PER_MP_LIMB == 32
246 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x80000000 };
247 #elif BITS_PER_MP_LIMB == 64
248 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x8000000000000000 };
249 #elif BITS_PER_MP_LIMB == 96
250 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x800000000000000000000000 };
251 #elif BITS_PER_MP_LIMB == 128
252 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x80000000000000000000000000000000 };
253 #elif BITS_PER_MP_LIMB == 256
254 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
258 #elif BITS_PER_MP_LIMB == 16
259 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x8000 };
260 #elif BITS_PER_MP_LIMB == 32
261 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x00000000, 0x00000000, 0x80000000 };
262 #elif BITS_PER_MP_LIMB == 64
263 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x0000000000000000, 0x8000000000000000 };
264 #elif BITS_PER_MP_LIMB == 96
265 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x800000000000000000000000 };
266 #elif BITS_PER_MP_LIMB == 128
267 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x80000000000000000000000000000000 };
268 #elif BITS_PER_MP_LIMB == 256
269 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
273 #elif BITS_PER_MP_LIMB == 16
274 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0x0e00, 0xcae0 };
275 #elif BITS_PER_MP_LIMB == 32
276 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e00 };
277 #elif BITS_PER_MP_LIMB == 64
278 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e0000000000 };
279 #elif BITS_PER_MP_LIMB == 96
280 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e000000000000000000 };
281 #elif BITS_PER_MP_LIMB == 128
282 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e00000000000000000000000000 };
283 #elif BITS_PER_MP_LIMB == 256
284 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e0000000000000000000000000000000000000000000000000000000000 };
288 #elif BITS_PER_MP_LIMB == 16
289 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0x0448, 0xe94e, 0xa9a9, 0x9cc1, 0xa184 };
290 #elif BITS_PER_MP_LIMB == 32
291 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0x04480000, 0xa9a9e94e, 0xa1849cc1 };
292 #elif BITS_PER_MP_LIMB == 64
293 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0x0448000000000000, 0xa1849cc1a9a9e94e };
294 #elif BITS_PER_MP_LIMB == 96
295 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0xa1849cc1a9a9e94e04480000 };
296 #elif BITS_PER_MP_LIMB == 128
297 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0xa1849cc1a9a9e94e0448000000000000 };
298 #elif BITS_PER_MP_LIMB == 256
299 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0xa1849cc1a9a9e94e044800000000000000000000000000000000000000000000 };
303 #elif BITS_PER_MP_LIMB == 16
304 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x0000, 0x8000 };
305 #elif BITS_PER_MP_LIMB == 32
306 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x80000000 };
307 #elif BITS_PER_MP_LIMB == 64
308 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x8000000000000000 };
309 #elif BITS_PER_MP_LIMB == 96
310 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x800000000000000000000000 };
311 #elif BITS_PER_MP_LIMB == 128
312 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x80000000000000000000000000000000 };
313 #elif BITS_PER_MP_LIMB == 256
314 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
318 #elif BITS_PER_MP_LIMB == 16
319 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x8000 };
320 #elif BITS_PER_MP_LIMB == 32
321 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x00000000, 0x00000000, 0x80000000 };
322 #elif BITS_PER_MP_LIMB == 64
323 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x0000000000000000, 0x8000000000000000 };
324 #elif BITS_PER_MP_LIMB == 96
325 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x800000000000000000000000 };
326 #elif BITS_PER_MP_LIMB == 128
327 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x80000000000000000000000000000000 };
328 #elif BITS_PER_MP_LIMB == 256
329 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
333 #elif BITS_PER_MP_LIMB == 16
334 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x7a00, 0x949a };
335 #elif BITS_PER_MP_LIMB == 32
336 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a00 };
337 #elif BITS_PER_MP_LIMB == 64
338 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a0000000000 };
339 #elif BITS_PER_MP_LIMB == 96
340 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a000000000000000000 };
341 #elif BITS_PER_MP_LIMB == 128
342 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a00000000000000000000000000 };
343 #elif BITS_PER_MP_LIMB == 256
344 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a0000000000000000000000000000000000000000000000000000000000 };
348 #elif BITS_PER_MP_LIMB == 16
349 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0x67b8, 0x9728, 0x287b, 0xa348, 0xdc81 };
350 #elif BITS_PER_MP_LIMB == 32
351 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0x67b80000, 0x287b9728, 0xdc81a348 };
352 #elif BITS_PER_MP_LIMB == 64
353 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0x67b8000000000000, 0xdc81a348287b9728 };
354 #elif BITS_PER_MP_LIMB == 96
355 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0xdc81a348287b972867b80000 };
356 #elif BITS_PER_MP_LIMB == 128
357 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0xdc81a348287b972867b8000000000000 };
358 #elif BITS_PER_MP_LIMB == 256
359 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0xdc81a348287b972867b800000000000000000000000000000000000000000000 };
363 #elif BITS_PER_MP_LIMB == 16
364 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0x0800, 0xa570 };
365 #elif BITS_PER_MP_LIMB == 32
366 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa5700800 };
367 #elif BITS_PER_MP_LIMB == 64
368 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa570080000000000 };
369 #elif BITS_PER_MP_LIMB == 96
370 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa57008000000000000000000 };
371 #elif BITS_PER_MP_LIMB == 128
372 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa5700800000000000000000000000000 };
373 #elif BITS_PER_MP_LIMB == 256
374 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa570080000000000000000000000000000000000000000000000000000000000 };
378 #elif BITS_PER_MP_LIMB == 16
379 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xff10, 0xf9e9, 0xe054, 0x9236, 0xc611 };
380 #elif BITS_PER_MP_LIMB == 32
381 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xff100000, 0xe054f9e9, 0xc6119236 };
382 #elif BITS_PER_MP_LIMB == 64
383 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xff10000000000000, 0xc6119236e054f9e9 };
384 #elif BITS_PER_MP_LIMB == 96
385 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xc6119236e054f9e9ff100000 };
386 #elif BITS_PER_MP_LIMB == 128
387 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xc6119236e054f9e9ff10000000000000 };
388 #elif BITS_PER_MP_LIMB == 256
389 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xc6119236e054f9e9ff1000000000000000000000000000000000000000000000 };
393 #elif BITS_PER_MP_LIMB == 16
394 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb400, 0xb3ab };
395 #elif BITS_PER_MP_LIMB == 32
396 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb400 };
397 #elif BITS_PER_MP_LIMB == 64
398 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb40000000000 };
399 #elif BITS_PER_MP_LIMB == 96
400 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb4000000000000000000 };
401 #elif BITS_PER_MP_LIMB == 128
402 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb400000000000000000000000000 };
403 #elif BITS_PER_MP_LIMB == 256
404 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb40000000000000000000000000000000000000000000000000000000000 };
408 #elif BITS_PER_MP_LIMB == 16
409 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0x37b8, 0xa711, 0x754d, 0xc9d6, 0xb660 };
410 #elif BITS_PER_MP_LIMB == 32
411 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0x37b80000, 0x754da711, 0xb660c9d6 };
412 #elif BITS_PER_MP_LIMB == 64
413 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0x37b8000000000000, 0xb660c9d6754da711 };
414 #elif BITS_PER_MP_LIMB == 96
415 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0xb660c9d6754da71137b80000 };
416 #elif BITS_PER_MP_LIMB == 128
417 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0xb660c9d6754da71137b8000000000000 };
418 #elif BITS_PER_MP_LIMB == 256
419 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0xb660c9d6754da71137b800000000000000000000000000000000000000000000 };
423 #elif BITS_PER_MP_LIMB == 16
424 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0x0000, 0xc000 };
425 #elif BITS_PER_MP_LIMB == 32
426 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc0000000 };
427 #elif BITS_PER_MP_LIMB == 64
428 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc000000000000000 };
429 #elif BITS_PER_MP_LIMB == 96
430 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc00000000000000000000000 };
431 #elif BITS_PER_MP_LIMB == 128
432 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc0000000000000000000000000000000 };
433 #elif BITS_PER_MP_LIMB == 256
434 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc000000000000000000000000000000000000000000000000000000000000000 };
438 #elif BITS_PER_MP_LIMB == 16
439 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaab0, 0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa };
440 #elif BITS_PER_MP_LIMB == 32
441 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaab00000, 0xaaaaaaaa, 0xaaaaaaaa };
442 #elif BITS_PER_MP_LIMB == 64
443 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaab0000000000000, 0xaaaaaaaaaaaaaaaa };
444 #elif BITS_PER_MP_LIMB == 96
445 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaaaaaaaaaaaaaaaaaab00000 };
446 #elif BITS_PER_MP_LIMB == 128
447 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaaaaaaaaaaaaaaaaaab0000000000000 };
448 #elif BITS_PER_MP_LIMB == 256
449 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaaaaaaaaaaaaaaaaaab000000000000000000000000000000000000000000000 };
453 #elif BITS_PER_MP_LIMB == 16
454 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0x0e00, 0xcae0 };
455 #elif BITS_PER_MP_LIMB == 32
456 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e00 };
457 #elif BITS_PER_MP_LIMB == 64
458 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e0000000000 };
459 #elif BITS_PER_MP_LIMB == 96
460 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e000000000000000000 };
461 #elif BITS_PER_MP_LIMB == 128
462 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e00000000000000000000000000 };
463 #elif BITS_PER_MP_LIMB == 256
464 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e0000000000000000000000000000000000000000000000000000000000 };
468 #elif BITS_PER_MP_LIMB == 16
469 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0x0448, 0xe94e, 0xa9a9, 0x9cc1, 0xa184 };
470 #elif BITS_PER_MP_LIMB == 32
471 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0x04480000, 0xa9a9e94e, 0xa1849cc1 };
472 #elif BITS_PER_MP_LIMB == 64
473 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0x0448000000000000, 0xa1849cc1a9a9e94e };
474 #elif BITS_PER_MP_LIMB == 96
475 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0xa1849cc1a9a9e94e04480000 };
476 #elif BITS_PER_MP_LIMB == 128
477 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0xa1849cc1a9a9e94e0448000000000000 };
478 #elif BITS_PER_MP_LIMB == 256
479 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0xa1849cc1a9a9e94e044800000000000000000000000000000000000000000000 };
483 #elif BITS_PER_MP_LIMB == 16
484 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0x7a00, 0xd49a };
485 #elif BITS_PER_MP_LIMB == 32
486 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a00 };
487 #elif BITS_PER_MP_LIMB == 64
488 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a0000000000 };
489 #elif BITS_PER_MP_LIMB == 96
490 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a000000000000000000 };
491 #elif BITS_PER_MP_LIMB == 128
492 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a00000000000000000000000000 };
493 #elif BITS_PER_MP_LIMB == 256
494 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a0000000000000000000000000000000000000000000000000000000000 };
498 #elif BITS_PER_MP_LIMB == 16
499 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x8f90, 0xf798, 0xfbcf, 0x9a84, 0x9a20 };
500 #elif BITS_PER_MP_LIMB == 32
501 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x8f900000, 0xfbcff798, 0x9a209a84 };
502 #elif BITS_PER_MP_LIMB == 64
503 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x8f90000000000000, 0x9a209a84fbcff798 };
504 #elif BITS_PER_MP_LIMB == 96
505 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x9a209a84fbcff7988f900000 };
506 #elif BITS_PER_MP_LIMB == 128
507 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x9a209a84fbcff7988f90000000000000 };
508 #elif BITS_PER_MP_LIMB == 256
509 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x9a209a84fbcff7988f9000000000000000000000000000000000000000000000 };
513 #elif BITS_PER_MP_LIMB == 16
514 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0x5400, 0xdd67 };
515 #elif BITS_PER_MP_LIMB == 32
516 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd675400 };
517 #elif BITS_PER_MP_LIMB == 64
518 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd67540000000000 };
519 #elif BITS_PER_MP_LIMB == 96
520 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd6754000000000000000000 };
521 #elif BITS_PER_MP_LIMB == 128
522 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd675400000000000000000000000000 };
523 #elif BITS_PER_MP_LIMB == 256
524 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd67540000000000000000000000000000000000000000000000000000000000 };
528 #elif BITS_PER_MP_LIMB == 16
529 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0xe170, 0x9d10, 0xeb22, 0x4e0e, 0x9400 };
530 #elif BITS_PER_MP_LIMB == 32
531 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0xe1700000, 0xeb229d10, 0x94004e0e };
532 #elif BITS_PER_MP_LIMB == 64
533 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0xe170000000000000, 0x94004e0eeb229d10 };
534 #elif BITS_PER_MP_LIMB == 96
535 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0x94004e0eeb229d10e1700000 };
536 #elif BITS_PER_MP_LIMB == 128
537 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0x94004e0eeb229d10e170000000000000 };
538 #elif BITS_PER_MP_LIMB == 256
539 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0x94004e0eeb229d10e17000000000000000000000000000000000000000000000 };
543 #elif BITS_PER_MP_LIMB == 16
544 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0x0800, 0xe570 };
545 #elif BITS_PER_MP_LIMB == 32
546 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe5700800 };
547 #elif BITS_PER_MP_LIMB == 64
548 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe570080000000000 };
549 #elif BITS_PER_MP_LIMB == 96
550 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe57008000000000000000000 };
551 #elif BITS_PER_MP_LIMB == 128
552 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe5700800000000000000000000000000 };
553 #elif BITS_PER_MP_LIMB == 256
554 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe570080000000000000000000000000000000000000000000000000000000000 };
558 #elif BITS_PER_MP_LIMB == 16
559 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0xfe28, 0x1c24, 0x0b03, 0x9c1a, 0x8ed1 };
560 #elif BITS_PER_MP_LIMB == 32
561 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0xfe280000, 0x0b031c24, 0x8ed19c1a };
562 #elif BITS_PER_MP_LIMB == 64
563 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0xfe28000000000000, 0x8ed19c1a0b031c24 };
564 #elif BITS_PER_MP_LIMB == 96
565 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0x8ed19c1a0b031c24fe280000 };
566 #elif BITS_PER_MP_LIMB == 128
567 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0x8ed19c1a0b031c24fe28000000000000 };
568 #elif BITS_PER_MP_LIMB == 256
569 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0x8ed19c1a0b031c24fe2800000000000000000000000000000000000000000000 };
573 #elif BITS_PER_MP_LIMB == 16
574 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0x0200, 0xecd4 };
575 #elif BITS_PER_MP_LIMB == 32
576 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd40200 };
577 #elif BITS_PER_MP_LIMB == 64
578 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd4020000000000 };
579 #elif BITS_PER_MP_LIMB == 96
580 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd402000000000000000000 };
581 #elif BITS_PER_MP_LIMB == 128
582 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd40200000000000000000000000000 };
583 #elif BITS_PER_MP_LIMB == 256
584 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd4020000000000000000000000000000000000000000000000000000000000 };
588 #elif BITS_PER_MP_LIMB == 16
589 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x57f8, 0xf7b4, 0xcb20, 0xa7c6, 0x8a5c };
590 #elif BITS_PER_MP_LIMB == 32
591 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x57f80000, 0xcb20f7b4, 0x8a5ca7c6 };
592 #elif BITS_PER_MP_LIMB == 64
593 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x57f8000000000000, 0x8a5ca7c6cb20f7b4 };
594 #elif BITS_PER_MP_LIMB == 96
595 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x8a5ca7c6cb20f7b457f80000 };
596 #elif BITS_PER_MP_LIMB == 128
597 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x8a5ca7c6cb20f7b457f8000000000000 };
598 #elif BITS_PER_MP_LIMB == 256
599 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x8a5ca7c6cb20f7b457f800000000000000000000000000000000000000000000 };
603 #elif BITS_PER_MP_LIMB == 16
604 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xb400, 0xf3ab };
605 #elif BITS_PER_MP_LIMB == 32
606 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb400 };
607 #elif BITS_PER_MP_LIMB == 64
608 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb40000000000 };
609 #elif BITS_PER_MP_LIMB == 96
610 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb4000000000000000000 };
611 #elif BITS_PER_MP_LIMB == 128
612 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb400000000000000000000000000 };
613 #elif BITS_PER_MP_LIMB == 256
614 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb40000000000000000000000000000000000000000000000000000000000 };
618 #elif BITS_PER_MP_LIMB == 16
619 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x85a8, 0x5cab, 0x96b5, 0xfff6, 0x8679 };
620 #elif BITS_PER_MP_LIMB == 32
621 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x85a80000, 0x96b55cab, 0x8679fff6 };
622 #elif BITS_PER_MP_LIMB == 64
623 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x85a8000000000000, 0x8679fff696b55cab };
624 #elif BITS_PER_MP_LIMB == 96
625 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x8679fff696b55cab85a80000 };
626 #elif BITS_PER_MP_LIMB == 128
627 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x8679fff696b55cab85a8000000000000 };
628 #elif BITS_PER_MP_LIMB == 256
629 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x8679fff696b55cab85a800000000000000000000000000000000000000000000 };
633 #elif BITS_PER_MP_LIMB == 16
634 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0x8000, 0xfa0a };
635 #elif BITS_PER_MP_LIMB == 32
636 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a8000 };
637 #elif BITS_PER_MP_LIMB == 64
638 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a800000000000 };
639 #elif BITS_PER_MP_LIMB == 96
640 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a80000000000000000000 };
641 #elif BITS_PER_MP_LIMB == 128
642 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a8000000000000000000000000000 };
643 #elif BITS_PER_MP_LIMB == 256
644 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a800000000000000000000000000000000000000000000000000000000000 };
648 #elif BITS_PER_MP_LIMB == 16
649 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x6f80, 0xa6aa, 0x69f0, 0xee23, 0x830c };
650 #elif BITS_PER_MP_LIMB == 32
651 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x6f800000, 0x69f0a6aa, 0x830cee23 };
652 #elif BITS_PER_MP_LIMB == 64
653 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x6f80000000000000, 0x830cee2369f0a6aa };
654 #elif BITS_PER_MP_LIMB == 96
655 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x830cee2369f0a6aa6f800000 };
656 #elif BITS_PER_MP_LIMB == 128
657 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x830cee2369f0a6aa6f80000000000000 };
658 #elif BITS_PER_MP_LIMB == 256
659 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x830cee2369f0a6aa6f8000000000000000000000000000000000000000000000 };
663 #elif BITS_PER_MP_LIMB == 16
664 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x0000, 0x8000 };
665 #elif BITS_PER_MP_LIMB == 32
666 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x80000000 };
667 #elif BITS_PER_MP_LIMB == 64
668 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x8000000000000000 };
669 #elif BITS_PER_MP_LIMB == 96
670 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x800000000000000000000000 };
671 #elif BITS_PER_MP_LIMB == 128
672 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x80000000000000000000000000000000 };
673 #elif BITS_PER_MP_LIMB == 256
674 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
678 #elif BITS_PER_MP_LIMB == 16
679 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x8000 };
680 #elif BITS_PER_MP_LIMB == 32
681 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x00000000, 0x00000000, 0x80000000 };
682 #elif BITS_PER_MP_LIMB == 64
683 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x0000000000000000, 0x8000000000000000 };
684 #elif BITS_PER_MP_LIMB == 96
685 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x800000000000000000000000 };
686 #elif BITS_PER_MP_LIMB == 128
687 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x80000000000000000000000000000000 };
688 #elif BITS_PER_MP_LIMB == 256
689 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
693 #elif BITS_PER_MP_LIMB == 16
694 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x8000, 0x82cc };
695 #elif BITS_PER_MP_LIMB == 32
696 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc8000 };
697 #elif BITS_PER_MP_LIMB == 64
698 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc800000000000 };
699 #elif BITS_PER_MP_LIMB == 96
700 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc80000000000000000000 };
701 #elif BITS_PER_MP_LIMB == 128
702 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc8000000000000000000000000000 };
703 #elif BITS_PER_MP_LIMB == 256
704 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc800000000000000000000000000000000000000000000000000000000000 };
708 #elif BITS_PER_MP_LIMB == 16
709 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0x8720, 0x259b, 0x62c4, 0xabf5, 0xfa85 };
710 #elif BITS_PER_MP_LIMB == 32
711 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0x87200000, 0x62c4259b, 0xfa85abf5 };
712 #elif BITS_PER_MP_LIMB == 64
713 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0x8720000000000000, 0xfa85abf562c4259b };
714 #elif BITS_PER_MP_LIMB == 96
715 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0xfa85abf562c4259b87200000 };
716 #elif BITS_PER_MP_LIMB == 128
717 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0xfa85abf562c4259b8720000000000000 };
718 #elif BITS_PER_MP_LIMB == 256
719 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0xfa85abf562c4259b872000000000000000000000000000000000000000000000 };
723 #elif BITS_PER_MP_LIMB == 16
724 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x0800, 0x8570 };
725 #elif BITS_PER_MP_LIMB == 32
726 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x85700800 };
727 #elif BITS_PER_MP_LIMB == 64
728 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x8570080000000000 };
729 #elif BITS_PER_MP_LIMB == 96
730 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x857008000000000000000000 };
731 #elif BITS_PER_MP_LIMB == 128
732 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x85700800000000000000000000000000 };
733 #elif BITS_PER_MP_LIMB == 256
734 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x8570080000000000000000000000000000000000000000000000000000000000 };
738 #elif BITS_PER_MP_LIMB == 16
739 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0x3698, 0x1378, 0x5537, 0x6634, 0xf591 };
740 #elif BITS_PER_MP_LIMB == 32
741 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0x36980000, 0x55371378, 0xf5916634 };
742 #elif BITS_PER_MP_LIMB == 64
743 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0x3698000000000000, 0xf591663455371378 };
744 #elif BITS_PER_MP_LIMB == 96
745 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0xf59166345537137836980000 };
746 #elif BITS_PER_MP_LIMB == 128
747 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0xf5916634553713783698000000000000 };
748 #elif BITS_PER_MP_LIMB == 256
749 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0xf591663455371378369800000000000000000000000000000000000000000000 };
753 #elif BITS_PER_MP_LIMB == 16
754 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x0600, 0x87ef };
755 #elif BITS_PER_MP_LIMB == 32
756 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef0600 };
757 #elif BITS_PER_MP_LIMB == 64
758 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef060000000000 };
759 #elif BITS_PER_MP_LIMB == 96
760 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef06000000000000000000 };
761 #elif BITS_PER_MP_LIMB == 128
762 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef0600000000000000000000000000 };
763 #elif BITS_PER_MP_LIMB == 256
764 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef060000000000000000000000000000000000000000000000000000000000 };
768 #elif BITS_PER_MP_LIMB == 16
769 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0x0db8, 0x558c, 0x62ed, 0x08c0, 0xf10f };
770 #elif BITS_PER_MP_LIMB == 32
771 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0x0db80000, 0x62ed558c, 0xf10f08c0 };
772 #elif BITS_PER_MP_LIMB == 64
773 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0x0db8000000000000, 0xf10f08c062ed558c };
774 #elif BITS_PER_MP_LIMB == 96
775 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0xf10f08c062ed558c0db80000 };
776 #elif BITS_PER_MP_LIMB == 128
777 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0xf10f08c062ed558c0db8000000000000 };
778 #elif BITS_PER_MP_LIMB == 256
779 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0xf10f08c062ed558c0db800000000000000000000000000000000000000000000 };
783 #elif BITS_PER_MP_LIMB == 16
784 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x3e00, 0x8a4d };
785 #elif BITS_PER_MP_LIMB == 32
786 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e00 };
787 #elif BITS_PER_MP_LIMB == 64
788 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e0000000000 };
789 #elif BITS_PER_MP_LIMB == 96
790 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e000000000000000000 };
791 #elif BITS_PER_MP_LIMB == 128
792 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e00000000000000000000000000 };
793 #elif BITS_PER_MP_LIMB == 256
794 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e0000000000000000000000000000000000000000000000000000000000 };
798 #elif BITS_PER_MP_LIMB == 16
799 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0x0b40, 0xa71c, 0x1cc1, 0x690a, 0xecee };
800 #elif BITS_PER_MP_LIMB == 32
801 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0x0b400000, 0x1cc1a71c, 0xecee690a };
802 #elif BITS_PER_MP_LIMB == 64
803 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0x0b40000000000000, 0xecee690a1cc1a71c };
804 #elif BITS_PER_MP_LIMB == 96
805 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0xecee690a1cc1a71c0b400000 };
806 #elif BITS_PER_MP_LIMB == 128
807 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0xecee690a1cc1a71c0b40000000000000 };
808 #elif BITS_PER_MP_LIMB == 256
809 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0xecee690a1cc1a71c0b4000000000000000000000000000000000000000000000 };
813 #elif BITS_PER_MP_LIMB == 16
814 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0xde00, 0x8c8d };
815 #elif BITS_PER_MP_LIMB == 32
816 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde00 };
817 #elif BITS_PER_MP_LIMB == 64
818 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde0000000000 };
819 #elif BITS_PER_MP_LIMB == 96
820 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde000000000000000000 };
821 #elif BITS_PER_MP_LIMB == 128
822 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde00000000000000000000000000 };
823 #elif BITS_PER_MP_LIMB == 256
824 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde0000000000000000000000000000000000000000000000000000000000 };
828 #elif BITS_PER_MP_LIMB == 16
829 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0x4108, 0x6b26, 0xb3d0, 0x63c1, 0xe922 };
830 #elif BITS_PER_MP_LIMB == 32
831 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0x41080000, 0xb3d06b26, 0xe92263c1 };
832 #elif BITS_PER_MP_LIMB == 64
833 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0x4108000000000000, 0xe92263c1b3d06b26 };
834 #elif BITS_PER_MP_LIMB == 96
835 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0xe92263c1b3d06b2641080000 };
836 #elif BITS_PER_MP_LIMB == 128
837 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0xe92263c1b3d06b264108000000000000 };
838 #elif BITS_PER_MP_LIMB == 256
839 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0xe92263c1b3d06b26410800000000000000000000000000000000000000000000 };
843 #elif BITS_PER_MP_LIMB == 16
844 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0xaa00, 0x8eb3 };
845 #elif BITS_PER_MP_LIMB == 32
846 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa00 };
847 #elif BITS_PER_MP_LIMB == 64
848 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa0000000000 };
849 #elif BITS_PER_MP_LIMB == 96
850 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa000000000000000000 };
851 #elif BITS_PER_MP_LIMB == 128
852 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa00000000000000000000000000 };
853 #elif BITS_PER_MP_LIMB == 256
854 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa0000000000000000000000000000000000000000000000000000000000 };
858 #elif BITS_PER_MP_LIMB == 16
859 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xdbe8, 0xf061, 0x60b9, 0x2c4d, 0xe5a0 };
860 #elif BITS_PER_MP_LIMB == 32
861 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xdbe80000, 0x60b9f061, 0xe5a02c4d };
862 #elif BITS_PER_MP_LIMB == 64
863 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xdbe8000000000000, 0xe5a02c4d60b9f061 };
864 #elif BITS_PER_MP_LIMB == 96
865 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xe5a02c4d60b9f061dbe80000 };
866 #elif BITS_PER_MP_LIMB == 128
867 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xe5a02c4d60b9f061dbe8000000000000 };
868 #elif BITS_PER_MP_LIMB == 256
869 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xe5a02c4d60b9f061dbe800000000000000000000000000000000000000000000 };
873 #elif BITS_PER_MP_LIMB == 16
874 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x0600, 0x90c1 };
875 #elif BITS_PER_MP_LIMB == 32
876 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c10600 };
877 #elif BITS_PER_MP_LIMB == 64
878 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c1060000000000 };
879 #elif BITS_PER_MP_LIMB == 96
880 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c106000000000000000000 };
881 #elif BITS_PER_MP_LIMB == 128
882 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c10600000000000000000000000000 };
883 #elif BITS_PER_MP_LIMB == 256
884 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c1060000000000000000000000000000000000000000000000000000000000 };
888 #elif BITS_PER_MP_LIMB == 16
889 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xc3e0, 0x586a, 0x46b9, 0xcadd, 0xe25e };
890 #elif BITS_PER_MP_LIMB == 32
891 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xc3e00000, 0x46b9586a, 0xe25ecadd };
892 #elif BITS_PER_MP_LIMB == 64
893 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xc3e0000000000000, 0xe25ecadd46b9586a };
894 #elif BITS_PER_MP_LIMB == 96
895 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xe25ecadd46b9586ac3e00000 };
896 #elif BITS_PER_MP_LIMB == 128
897 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xe25ecadd46b9586ac3e0000000000000 };
898 #elif BITS_PER_MP_LIMB == 256
899 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xe25ecadd46b9586ac3e000000000000000000000000000000000000000000000 };
903 #elif BITS_PER_MP_LIMB == 16
904 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x0400, 0x92b8 };
905 #elif BITS_PER_MP_LIMB == 32
906 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b80400 };
907 #elif BITS_PER_MP_LIMB == 64
908 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b8040000000000 };
909 #elif BITS_PER_MP_LIMB == 96
910 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b804000000000000000000 };
911 #elif BITS_PER_MP_LIMB == 128
912 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b80400000000000000000000000000 };
913 #elif BITS_PER_MP_LIMB == 256
914 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b8040000000000000000000000000000000000000000000000000000000000 };
918 #elif BITS_PER_MP_LIMB == 16
919 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0x3668, 0x7263, 0xc7c6, 0xbb44, 0xdf56 };
920 #elif BITS_PER_MP_LIMB == 32
921 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0x36680000, 0xc7c67263, 0xdf56bb44 };
922 #elif BITS_PER_MP_LIMB == 64
923 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0x3668000000000000, 0xdf56bb44c7c67263 };
924 #elif BITS_PER_MP_LIMB == 96
925 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0xdf56bb44c7c6726336680000 };
926 #elif BITS_PER_MP_LIMB == 128
927 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0xdf56bb44c7c672633668000000000000 };
928 #elif BITS_PER_MP_LIMB == 256
929 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0xdf56bb44c7c67263366800000000000000000000000000000000000000000000 };
933 #elif BITS_PER_MP_LIMB == 16
934 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x7a00, 0x949a };
935 #elif BITS_PER_MP_LIMB == 32
936 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a00 };
937 #elif BITS_PER_MP_LIMB == 64
938 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a0000000000 };
939 #elif BITS_PER_MP_LIMB == 96
940 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a000000000000000000 };
941 #elif BITS_PER_MP_LIMB == 128
942 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a00000000000000000000000000 };
943 #elif BITS_PER_MP_LIMB == 256
944 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a0000000000000000000000000000000000000000000000000000000000 };
948 #elif BITS_PER_MP_LIMB == 16
949 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0x67b8, 0x9728, 0x287b, 0xa348, 0xdc81 };
950 #elif BITS_PER_MP_LIMB == 32
951 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0x67b80000, 0x287b9728, 0xdc81a348 };
952 #elif BITS_PER_MP_LIMB == 64
953 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0x67b8000000000000, 0xdc81a348287b9728 };
954 #elif BITS_PER_MP_LIMB == 96
955 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0xdc81a348287b972867b80000 };
956 #elif BITS_PER_MP_LIMB == 128
957 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0xdc81a348287b972867b8000000000000 };
958 #elif BITS_PER_MP_LIMB == 256
959 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0xdc81a348287b972867b800000000000000000000000000000000000000000000 };
963 #elif BITS_PER_MP_LIMB == 16
964 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x0200, 0x966a };
965 #elif BITS_PER_MP_LIMB == 32
966 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a0200 };
967 #elif BITS_PER_MP_LIMB == 64
968 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a020000000000 };
969 #elif BITS_PER_MP_LIMB == 96
970 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a02000000000000000000 };
971 #elif BITS_PER_MP_LIMB == 128
972 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a0200000000000000000000000000 };
973 #elif BITS_PER_MP_LIMB == 256
974 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a020000000000000000000000000000000000000000000000000000000000 };
978 #elif BITS_PER_MP_LIMB == 16
979 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0x6458, 0x78a4, 0x7583, 0x19f9, 0xd9da };
980 #elif BITS_PER_MP_LIMB == 32
981 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0x64580000, 0x758378a4, 0xd9da19f9 };
982 #elif BITS_PER_MP_LIMB == 64
983 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0x6458000000000000, 0xd9da19f9758378a4 };
984 #elif BITS_PER_MP_LIMB == 96
985 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0xd9da19f9758378a464580000 };
986 #elif BITS_PER_MP_LIMB == 128
987 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0xd9da19f9758378a46458000000000000 };
988 #elif BITS_PER_MP_LIMB == 256
989 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0xd9da19f9758378a4645800000000000000000000000000000000000000000000 };
993 #elif BITS_PER_MP_LIMB == 16
994 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x0a00, 0x9828 };
995 #elif BITS_PER_MP_LIMB == 32
996 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a00 };
997 #elif BITS_PER_MP_LIMB == 64
998 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a0000000000 };
999 #elif BITS_PER_MP_LIMB == 96
1000 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a000000000000000000 };
1001 #elif BITS_PER_MP_LIMB == 128
1002 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a00000000000000000000000000 };
1003 #elif BITS_PER_MP_LIMB == 256
1004 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a0000000000000000000000000000000000000000000000000000000000 };
1008 #elif BITS_PER_MP_LIMB == 16
1009 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0x5b08, 0xe1bd, 0xe237, 0x7bac, 0xd75b };
1010 #elif BITS_PER_MP_LIMB == 32
1011 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0x5b080000, 0xe237e1bd, 0xd75b7bac };
1012 #elif BITS_PER_MP_LIMB == 64
1013 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0x5b08000000000000, 0xd75b7bace237e1bd };
1014 #elif BITS_PER_MP_LIMB == 96
1015 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0xd75b7bace237e1bd5b080000 };
1016 #elif BITS_PER_MP_LIMB == 128
1017 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0xd75b7bace237e1bd5b08000000000000 };
1018 #elif BITS_PER_MP_LIMB == 256
1019 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0xd75b7bace237e1bd5b0800000000000000000000000000000000000000000000 };
1023 #elif BITS_PER_MP_LIMB == 16
1024 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0xda00, 0x99d5 };
1025 #elif BITS_PER_MP_LIMB == 32
1026 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da00 };
1027 #elif BITS_PER_MP_LIMB == 64
1028 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da0000000000 };
1029 #elif BITS_PER_MP_LIMB == 96
1030 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da000000000000000000 };
1031 #elif BITS_PER_MP_LIMB == 128
1032 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da00000000000000000000000000 };
1033 #elif BITS_PER_MP_LIMB == 256
1034 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da0000000000000000000000000000000000000000000000000000000000 };
1038 #elif BITS_PER_MP_LIMB == 16
1039 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xdeb8, 0xe8b8, 0x71df, 0xc758, 0xd501 };
1040 #elif BITS_PER_MP_LIMB == 32
1041 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xdeb80000, 0x71dfe8b8, 0xd501c758 };
1042 #elif BITS_PER_MP_LIMB == 64
1043 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xdeb8000000000000, 0xd501c75871dfe8b8 };
1044 #elif BITS_PER_MP_LIMB == 96
1045 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xd501c75871dfe8b8deb80000 };
1046 #elif BITS_PER_MP_LIMB == 128
1047 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xd501c75871dfe8b8deb8000000000000 };
1048 #elif BITS_PER_MP_LIMB == 256
1049 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xd501c75871dfe8b8deb800000000000000000000000000000000000000000000 };
1053 #elif BITS_PER_MP_LIMB == 16
1054 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9600, 0x9b74 };
1055 #elif BITS_PER_MP_LIMB == 32
1056 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b749600 };
1057 #elif BITS_PER_MP_LIMB == 64
1058 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b74960000000000 };
1059 #elif BITS_PER_MP_LIMB == 96
1060 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b7496000000000000000000 };
1061 #elif BITS_PER_MP_LIMB == 128
1062 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b749600000000000000000000000000 };
1063 #elif BITS_PER_MP_LIMB == 256
1064 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b74960000000000000000000000000000000000000000000000000000000000 };
1068 #elif BITS_PER_MP_LIMB == 16
1069 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xccc8, 0x62b3, 0x9c6c, 0x8315, 0xd2c9 };
1070 #elif BITS_PER_MP_LIMB == 32
1071 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xccc80000, 0x9c6c62b3, 0xd2c98315 };
1072 #elif BITS_PER_MP_LIMB == 64
1073 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xccc8000000000000, 0xd2c983159c6c62b3 };
1074 #elif BITS_PER_MP_LIMB == 96
1075 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xd2c983159c6c62b3ccc80000 };
1076 #elif BITS_PER_MP_LIMB == 128
1077 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xd2c983159c6c62b3ccc8000000000000 };
1078 #elif BITS_PER_MP_LIMB == 256
1079 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xd2c983159c6c62b3ccc800000000000000000000000000000000000000000000 };
1083 #elif BITS_PER_MP_LIMB == 16
1084 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x4000, 0x9d05 };
1085 #elif BITS_PER_MP_LIMB == 32
1086 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d054000 };
1087 #elif BITS_PER_MP_LIMB == 64
1088 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d05400000000000 };
1089 #elif BITS_PER_MP_LIMB == 96
1090 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d0540000000000000000000 };
1091 #elif BITS_PER_MP_LIMB == 128
1092 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d054000000000000000000000000000 };
1093 #elif BITS_PER_MP_LIMB == 256
1094 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d05400000000000000000000000000000000000000000000000000000000000 };
1098 #elif BITS_PER_MP_LIMB == 16
1099 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0x3588, 0x1732, 0x5cad, 0xa619, 0xd0af };
1100 #elif BITS_PER_MP_LIMB == 32
1101 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0x35880000, 0x5cad1732, 0xd0afa619 };
1102 #elif BITS_PER_MP_LIMB == 64
1103 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0x3588000000000000, 0xd0afa6195cad1732 };
1104 #elif BITS_PER_MP_LIMB == 96
1105 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0xd0afa6195cad173235880000 };
1106 #elif BITS_PER_MP_LIMB == 128
1107 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0xd0afa6195cad17323588000000000000 };
1108 #elif BITS_PER_MP_LIMB == 256
1109 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0xd0afa6195cad1732358800000000000000000000000000000000000000000000 };
1113 #elif BITS_PER_MP_LIMB == 16
1114 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0xc800, 0x9e88 };
1115 #elif BITS_PER_MP_LIMB == 32
1116 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c800 };
1117 #elif BITS_PER_MP_LIMB == 64
1118 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c80000000000 };
1119 #elif BITS_PER_MP_LIMB == 96
1120 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c8000000000000000000 };
1121 #elif BITS_PER_MP_LIMB == 128
1122 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c800000000000000000000000000 };
1123 #elif BITS_PER_MP_LIMB == 256
1124 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c80000000000000000000000000000000000000000000000000000000000 };
1128 #elif BITS_PER_MP_LIMB == 16
1129 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xd578, 0xf7ca, 0x63ee, 0x86e6, 0xceb1 };
1130 #elif BITS_PER_MP_LIMB == 32
1131 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xd5780000, 0x63eef7ca, 0xceb186e6 };
1132 #elif BITS_PER_MP_LIMB == 64
1133 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xd578000000000000, 0xceb186e663eef7ca };
1134 #elif BITS_PER_MP_LIMB == 96
1135 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xceb186e663eef7cad5780000 };
1136 #elif BITS_PER_MP_LIMB == 128
1137 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xceb186e663eef7cad578000000000000 };
1138 #elif BITS_PER_MP_LIMB == 256
1139 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xceb186e663eef7cad57800000000000000000000000000000000000000000000 };
1143 #elif BITS_PER_MP_LIMB == 16
1144 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0x0000, 0xa000 };
1145 #elif BITS_PER_MP_LIMB == 32
1146 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa0000000 };
1147 #elif BITS_PER_MP_LIMB == 64
1148 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa000000000000000 };
1149 #elif BITS_PER_MP_LIMB == 96
1150 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa00000000000000000000000 };
1151 #elif BITS_PER_MP_LIMB == 128
1152 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa0000000000000000000000000000000 };
1153 #elif BITS_PER_MP_LIMB == 256
1154 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa000000000000000000000000000000000000000000000000000000000000000 };
1158 #elif BITS_PER_MP_LIMB == 16
1159 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccd0, 0xcccc, 0xcccc, 0xcccc, 0xcccc };
1160 #elif BITS_PER_MP_LIMB == 32
1161 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccd00000, 0xcccccccc, 0xcccccccc };
1162 #elif BITS_PER_MP_LIMB == 64
1163 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccd0000000000000, 0xcccccccccccccccc };
1164 #elif BITS_PER_MP_LIMB == 96
1165 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccccccccccccccccccd00000 };
1166 #elif BITS_PER_MP_LIMB == 128
1167 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccccccccccccccccccd0000000000000 };
1168 #elif BITS_PER_MP_LIMB == 256
1169 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccccccccccccccccccd000000000000000000000000000000000000000000000 };
1173 #elif BITS_PER_MP_LIMB == 16
1174 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xae00, 0xa16b };
1175 #elif BITS_PER_MP_LIMB == 32
1176 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae00 };
1177 #elif BITS_PER_MP_LIMB == 64
1178 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae0000000000 };
1179 #elif BITS_PER_MP_LIMB == 96
1180 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae000000000000000000 };
1181 #elif BITS_PER_MP_LIMB == 128
1182 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae00000000000000000000000000 };
1183 #elif BITS_PER_MP_LIMB == 256
1184 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae0000000000000000000000000000000000000000000000000000000000 };
1188 #elif BITS_PER_MP_LIMB == 16
1189 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0x0888, 0xa187, 0x5304, 0x6404, 0xcaff };
1190 #elif BITS_PER_MP_LIMB == 32
1191 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0x08880000, 0x5304a187, 0xcaff6404 };
1192 #elif BITS_PER_MP_LIMB == 64
1193 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0x0888000000000000, 0xcaff64045304a187 };
1194 #elif BITS_PER_MP_LIMB == 96
1195 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0xcaff64045304a18708880000 };
1196 #elif BITS_PER_MP_LIMB == 128
1197 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0xcaff64045304a1870888000000000000 };
1198 #elif BITS_PER_MP_LIMB == 256
1199 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0xcaff64045304a187088800000000000000000000000000000000000000000000 };
1203 #elif BITS_PER_MP_LIMB == 16
1204 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0x8000, 0xa2cc };
1205 #elif BITS_PER_MP_LIMB == 32
1206 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc8000 };
1207 #elif BITS_PER_MP_LIMB == 64
1208 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc800000000000 };
1209 #elif BITS_PER_MP_LIMB == 96
1210 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc80000000000000000000 };
1211 #elif BITS_PER_MP_LIMB == 128
1212 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc8000000000000000000000000000 };
1213 #elif BITS_PER_MP_LIMB == 256
1214 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc800000000000000000000000000000000000000000000000000000000000 };
1218 #elif BITS_PER_MP_LIMB == 16
1219 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xfb50, 0x17ca, 0x5a79, 0x73d8, 0xc947 };
1220 #elif BITS_PER_MP_LIMB == 32
1221 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xfb500000, 0x5a7917ca, 0xc94773d8 };
1222 #elif BITS_PER_MP_LIMB == 64
1223 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xfb50000000000000, 0xc94773d85a7917ca };
1224 #elif BITS_PER_MP_LIMB == 96
1225 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xc94773d85a7917cafb500000 };
1226 #elif BITS_PER_MP_LIMB == 128
1227 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xc94773d85a7917cafb50000000000000 };
1228 #elif BITS_PER_MP_LIMB == 256
1229 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xc94773d85a7917cafb5000000000000000000000000000000000000000000000 };
1233 #elif BITS_PER_MP_LIMB == 16
1234 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0x1800, 0xa423 };
1235 #elif BITS_PER_MP_LIMB == 32
1236 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa4231800 };
1237 #elif BITS_PER_MP_LIMB == 64
1238 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa423180000000000 };
1239 #elif BITS_PER_MP_LIMB == 96
1240 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa42318000000000000000000 };
1241 #elif BITS_PER_MP_LIMB == 128
1242 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa4231800000000000000000000000000 };
1243 #elif BITS_PER_MP_LIMB == 256
1244 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa423180000000000000000000000000000000000000000000000000000000000 };
1248 #elif BITS_PER_MP_LIMB == 16
1249 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0x6960, 0x18c2, 0x6037, 0x567c, 0xc7a3 };
1250 #elif BITS_PER_MP_LIMB == 32
1251 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0x69600000, 0x603718c2, 0xc7a3567c };
1252 #elif BITS_PER_MP_LIMB == 64
1253 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0x6960000000000000, 0xc7a3567c603718c2 };
1254 #elif BITS_PER_MP_LIMB == 96
1255 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0xc7a3567c603718c269600000 };
1256 #elif BITS_PER_MP_LIMB == 128
1257 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0xc7a3567c603718c26960000000000000 };
1258 #elif BITS_PER_MP_LIMB == 256
1259 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0xc7a3567c603718c2696000000000000000000000000000000000000000000000 };
1263 #elif BITS_PER_MP_LIMB == 16
1264 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0x0800, 0xa570 };
1265 #elif BITS_PER_MP_LIMB == 32
1266 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa5700800 };
1267 #elif BITS_PER_MP_LIMB == 64
1268 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa570080000000000 };
1269 #elif BITS_PER_MP_LIMB == 96
1270 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa57008000000000000000000 };
1271 #elif BITS_PER_MP_LIMB == 128
1272 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa5700800000000000000000000000000 };
1273 #elif BITS_PER_MP_LIMB == 256
1274 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa570080000000000000000000000000000000000000000000000000000000000 };
1278 #elif BITS_PER_MP_LIMB == 16
1279 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xff10, 0xf9e9, 0xe054, 0x9236, 0xc611 };
1280 #elif BITS_PER_MP_LIMB == 32
1281 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xff100000, 0xe054f9e9, 0xc6119236 };
1282 #elif BITS_PER_MP_LIMB == 64
1283 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xff10000000000000, 0xc6119236e054f9e9 };
1284 #elif BITS_PER_MP_LIMB == 96
1285 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xc6119236e054f9e9ff100000 };
1286 #elif BITS_PER_MP_LIMB == 128
1287 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xc6119236e054f9e9ff10000000000000 };
1288 #elif BITS_PER_MP_LIMB == 256
1289 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xc6119236e054f9e9ff1000000000000000000000000000000000000000000000 };
1292 const __mpfr_struct __gmpfr_l2b[BASE_MAX-1][2] = {
1293 { { 23, 1, 1, (mp_limb_t *) mpfr_l2b_2_0__tab },
1294 { 77, 1, 1, (mp_limb_t *) mpfr_l2b_2_1__tab } },
1295 { { 23, 1, 1, (mp_limb_t *) mpfr_l2b_3_0__tab },
1296 { 77, 1, 0, (mp_limb_t *) mpfr_l2b_3_1__tab } },
1297 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_4_0__tab },
1298 { 77, 1, 0, (mp_limb_t *) mpfr_l2b_4_1__tab } },
1299 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_5_0__tab },
1300 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_5_1__tab } },
1301 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_6_0__tab },
1302 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_6_1__tab } },
1303 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_7_0__tab },
1304 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_7_1__tab } },
1305 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_8_0__tab },
1306 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_8_1__tab } },
1307 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_9_0__tab },
1308 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_9_1__tab } },
1309 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_10_0__tab },
1310 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_10_1__tab } },
1311 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_11_0__tab },
1312 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_11_1__tab } },
1313 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_12_0__tab },
1314 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_12_1__tab } },
1315 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_13_0__tab },
1316 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_13_1__tab } },
1317 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_14_0__tab },
1318 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_14_1__tab } },
1319 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_15_0__tab },
1320 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_15_1__tab } },
1321 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_16_0__tab },
1322 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_16_1__tab } },
1323 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_17_0__tab },
1324 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_17_1__tab } },
1325 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_18_0__tab },
1326 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_18_1__tab } },
1327 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_19_0__tab },
1328 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_19_1__tab } },
1329 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_20_0__tab },
1330 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_20_1__tab } },
1331 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_21_0__tab },
1332 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_21_1__tab } },
1333 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_22_0__tab },
1334 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_22_1__tab } },
1335 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_23_0__tab },
1336 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_23_1__tab } },
1337 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_24_0__tab },
1338 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_24_1__tab } },
1339 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_25_0__tab },
1340 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_25_1__tab } },
1341 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_26_0__tab },
1342 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_26_1__tab } },
1343 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_27_0__tab },
1344 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_27_1__tab } },
1345 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_28_0__tab },
1346 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_28_1__tab } },
1347 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_29_0__tab },
1348 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_29_1__tab } },
1349 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_30_0__tab },
1350 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_30_1__tab } },
1351 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_31_0__tab },
1352 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_31_1__tab } },
1353 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_32_0__tab },
1354 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_32_1__tab } },
1355 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_33_0__tab },
1356 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_33_1__tab } },
1357 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_34_0__tab },
1358 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_34_1__tab } },
1359 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_35_0__tab },
1360 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_35_1__tab } },
1361 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_36_0__tab },
1362 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_36_1__tab } } };
1364 /***************************************************************************/
1366 /* returns ceil(e * log2(b)^((-1)^i)), or ... + 1 */
1368 ceil_mul (mp_exp_t e, int beta, int i)
1374 p = &__gmpfr_l2b[beta-2][i];
1375 mpfr_init2 (t, sizeof (mp_exp_t) * CHAR_BIT);
1376 mpfr_set_exp_t (t, e, GMP_RNDU);
1377 mpfr_mul (t, t, p, GMP_RNDU);
1378 r = mpfr_get_exp_t (t, GMP_RNDU);
1383 /* prints the mantissa of x in the string s, and writes the corresponding
1385 x is rounded with direction rnd, m is the number of digits of the mantissa,
1386 b is the given base (2 <= b <= 36).
1389 if s=NULL, allocates a string to store the mantissa, with
1390 m characters, plus a final '\0', plus a possible minus sign
1391 (thus m+1 or m+2 characters).
1393 Important: when you call this function with s=NULL, don't forget to free
1394 the memory space allocated, with free(s, strlen(s)).
1397 mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd)
1399 int exact; /* exact result */
1401 mp_exp_t prec; /* precision of the computation */
1412 int ret; /* return value of mpfr_get_str_aux */
1413 MPFR_ZIV_DECL (loop);
1414 MPFR_SAVE_EXPO_DECL (expo);
1415 MPFR_TMP_DECL(marker);
1417 /* if exact = 1 then err is undefined */
1418 /* otherwise err is such that |x*b^(m-g)-a*2^exp_a| < 2^(err+exp_a) */
1420 /* is the base valid? */
1421 if (b < 2 || b > 36)
1424 if (MPFR_UNLIKELY (MPFR_IS_NAN (x)))
1427 s = (char *) (*__gmp_allocate_func) (6);
1428 strcpy (s, "@NaN@");
1432 neg = MPFR_SIGN(x) < 0; /* 0 if positive, 1 if negative */
1434 if (MPFR_UNLIKELY (MPFR_IS_INF (x)))
1437 s = (char *) (*__gmp_allocate_func) (neg + 6);
1438 strcpy (s, (neg) ? "-@Inf@" : "@Inf@");
1442 MPFR_SAVE_EXPO_MARK (expo); /* needed for ceil_mul (at least) */
1447 /* take at least 1 + ceil(n*log(2)/log(b)) digits, where n is the
1448 number of bits of the mantissa, to ensure back conversion from
1449 the output gives the same floating-point.
1451 Warning: if b = 2^k, this may be too large. The worst case is when
1452 the first base-b digit contains only one bit, so we get
1453 1 + ceil((n-1)/k) = 2 + floor((n-2)/k) instead.
1455 m = 1 + ceil_mul (IS_POW2(b) ? MPFR_PREC(x) - 1 : MPFR_PREC(x), b, 1);
1460 /* the code below for non-power-of-two bases works for m=1 */
1461 MPFR_ASSERTN (m >= 2 || (IS_POW2(b) == 0 && m >= 1));
1463 /* x is a floating-point number */
1465 if (MPFR_IS_ZERO(x))
1468 s = (char*) (*__gmp_allocate_func) (neg + m + 1);
1474 *e = 0; /* a bit like frexp() in ISO C99 */
1475 MPFR_SAVE_EXPO_FREE (expo);
1476 return s0; /* strlen(s0) = neg + m */
1480 s = (char*) (*__gmp_allocate_func) (neg + m + 1);
1495 count_leading_zeros (pow2, (mp_limb_t) b);
1496 pow2 = BITS_PER_MP_LIMB - pow2 - 1; /* base = 2^pow2 */
1498 /* set MPFR_EXP(x) = f*pow2 + r, 1 <= r <= pow2 */
1499 f = (MPFR_GET_EXP (x) - 1) / pow2;
1500 r = MPFR_GET_EXP (x) - f * pow2;
1507 /* the first digit will contain only r bits */
1508 prec = (m - 1) * pow2 + r; /* total number of bits */
1509 n = (prec - 1) / BITS_PER_MP_LIMB + 1;
1511 MPFR_TMP_MARK (marker);
1512 x1 = (mp_limb_t*) MPFR_TMP_ALLOC((n + 1) * sizeof (mp_limb_t));
1513 nb = n * BITS_PER_MP_LIMB - prec;
1514 /* round xp to the precision prec, and put it into x1
1515 put the carry into x1[n] */
1516 if ((x1[n] = mpfr_round_raw (x1, xp, MPFR_PREC(x),
1517 MPFR_IS_STRICTNEG(x),
1518 prec, rnd, &inexp)))
1520 /* overflow when rounding x: x1 = 2^prec */
1521 if (r == pow2) /* prec = m * pow2,
1522 2^prec will need (m+1) digits in base 2^pow2 */
1524 /* divide x1 by 2^pow2, and increase the exponent */
1525 mpn_rshift (x1, x1, n + 1, pow2);
1528 else /* 2^prec needs still m digits, but x1 may need n+1 limbs */
1532 /* it remains to shift x1 by nb limbs to the right, since mpn_get_str
1533 expects a right-normalized number */
1536 mpn_rshift (x1, x1, n, nb);
1537 /* the most significant word may be zero */
1542 mpn_get_str ((unsigned char*) s, b, x1, n);
1544 s[i] = num_to_text[(int) s[i]];
1547 /* the exponent of s is f + 1 */
1550 MPFR_TMP_FREE(marker);
1551 MPFR_SAVE_EXPO_FREE (expo);
1555 /* if x < 0, reduce to x > 0 */
1557 rnd = MPFR_INVERT_RND(rnd);
1559 g = ceil_mul (MPFR_GET_EXP (x) - 1, b, 1);
1561 prec = ceil_mul (m, b, 0) + 1;
1562 exp = ((mp_exp_t) m < g) ? g - (mp_exp_t) m : (mp_exp_t) m - g;
1563 prec += MPFR_INT_CEIL_LOG2 (prec); /* number of guard bits */
1564 if (exp != 0) /* add maximal exponentiation error */
1565 prec += 3 * (mp_exp_t) MPFR_INT_CEIL_LOG2 (exp);
1567 MPFR_ZIV_INIT (loop, prec);
1570 MPFR_TMP_MARK(marker);
1574 /* number of limbs */
1575 n = 1 + (prec - 1) / BITS_PER_MP_LIMB;
1577 /* a will contain the approximation of the mantissa */
1578 a = (mp_limb_t*) MPFR_TMP_ALLOC (n * sizeof (mp_limb_t));
1580 nx = 1 + (MPFR_PREC(x) - 1) / BITS_PER_MP_LIMB;
1582 if ((mp_exp_t) m == g) /* final exponent is 0, no multiplication or
1583 division to perform */
1586 exact = mpn_scan1 (xp, 0) >= (nx - n) * BITS_PER_MP_LIMB;
1588 MPN_COPY2 (a, n, xp, nx);
1589 exp_a = MPFR_GET_EXP (x) - n * BITS_PER_MP_LIMB;
1591 else if ((mp_exp_t) m > g) /* we have to multiply x by b^exp */
1595 /* a2*2^exp_a = b^e */
1596 err = mpfr_mpn_exp (a, &exp_a, b, exp, n);
1597 /* here, the error on a is at most 2^err ulps */
1598 exact = (err == -1);
1600 /* x = x1*2^(n*BITS_PER_MP_LIMB) */
1601 x1 = (nx >= n) ? xp + nx - n : xp;
1602 nx1 = (nx >= n) ? n : nx; /* nx1 = min(n, nx) */
1607 ((mpn_scan1 (xp, 0) >= (nx - n) * BITS_PER_MP_LIMB)));
1609 /* we loose one more bit in the multiplication,
1610 except when err=0 where we loose two bits */
1611 err = (err <= 0) ? 2 : err + 1;
1613 /* result = a * x */
1614 result = (mp_limb_t*) MPFR_TMP_ALLOC ((n + nx1) * sizeof (mp_limb_t));
1615 mpn_mul (result, a, n, x1, nx1);
1616 exp_a += MPFR_GET_EXP (x);
1617 if (mpn_scan1 (result, 0) < (nx1 * BITS_PER_MP_LIMB))
1620 /* normalize a and truncate */
1621 if ((result[n + nx1 - 1] & MPFR_LIMB_HIGHBIT) == 0)
1623 mpn_lshift (a, result + nx1, n , 1);
1624 a[0] |= result[nx1 - 1] >> (BITS_PER_MP_LIMB - 1);
1628 MPN_COPY (a, result + nx1, n);
1634 /* a2*2^exp_a = b^e */
1635 err = mpfr_mpn_exp (a, &exp_a, b, exp, n);
1636 exact = (err == -1);
1638 /* allocate memory for x1, result and reste */
1639 x1 = (mp_limb_t*) MPFR_TMP_ALLOC (2 * n * sizeof (mp_limb_t));
1640 result = (mp_limb_t*) MPFR_TMP_ALLOC ((n + 1) * sizeof (mp_limb_t));
1641 reste = (mp_limb_t*) MPFR_TMP_ALLOC (n * sizeof (mp_limb_t));
1643 /* initialize x1 = x */
1644 MPN_COPY2 (x1, 2 * n, xp, nx);
1645 if ((exact) && (nx > 2 * n) &&
1646 (mpn_scan1 (xp, 0) < (nx - 2 * n) * BITS_PER_MP_LIMB))
1649 /* result = x / a */
1650 mpn_tdiv_qr (result, reste, 0, x1, 2 * n, a, n);
1651 exp_a = MPFR_GET_EXP (x) - exp_a - 2 * n * BITS_PER_MP_LIMB;
1653 /* test if division was exact */
1655 exact = mpn_popcount (reste, n) == 0;
1657 /* normalize the result and copy into a */
1660 mpn_rshift (a, result, n, 1);
1661 a[n - 1] |= MPFR_LIMB_HIGHBIT;;
1665 MPN_COPY (a, result, n);
1667 err = (err == -1) ? 2 : err + 2;
1670 /* check if rounding is possible */
1673 ret = mpfr_get_str_aux (s, e, a, n, exp_a, err, b, m, rnd);
1674 if (ret == MPFR_ROUND_FAILED)
1676 /* too large error: increment the working precision */
1677 MPFR_ZIV_NEXT (loop, prec);
1679 else if (ret == -MPFR_ROUND_FAILED)
1681 /* too many digits in mantissa: exp = |m-g| */
1682 if ((mp_exp_t) m > g) /* exp = m - g, multiply by b^exp */
1687 else /* exp = g - m, divide by b^exp */
1696 MPFR_TMP_FREE(marker);
1698 MPFR_ZIV_FREE (loop);
1702 MPFR_TMP_FREE(marker);
1703 MPFR_SAVE_EXPO_FREE (expo);
1707 void mpfr_free_str (char *str)
1709 (*__gmp_free_func) (str, strlen (str) + 1);