Actually hook powernow.4 into the build.
[dragonfly.git] / contrib / mpfr / get_str.c
blobfe5808f7c059e5d4878cbae55c415b9b73d9d52e
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 #include <string.h> /* For strlen */
26 #define MPFR_NEED_LONGLONG_H
27 #include "mpfr-impl.h"
29 static int mpfr_get_str_aux (char *const, mp_exp_t *const, mp_limb_t *const,
30 mp_size_t, mp_exp_t, long, int, size_t, mp_rnd_t);
32 /* The implicit \0 is useless, but we do not write num_to_text[36]
33 otherwise g++ complains. */
34 static const char num_to_text[] = "0123456789abcdefghijklmnopqrstuvwxyz";
36 /* copy most important limbs of {op, n2} in {rp, n1} */
37 /* if n1 > n2 put 0 in low limbs of {rp, n1} */
38 #define MPN_COPY2(rp, n1, op, n2) \
39 if ((n1) <= (n2)) \
40 { \
41 MPN_COPY ((rp), (op) + (n2) - (n1), (n1)); \
42 } \
43 else \
44 { \
45 MPN_COPY ((rp) + (n1) - (n2), (op), (n2)); \
46 MPN_ZERO ((rp), (n1) - (n2)); \
49 #define MPFR_ROUND_FAILED 3
51 /* Input: an approximation r*2^f of an real Y, with |r*2^f-Y| <= 2^(e+f).
52 Returns if possible in the string s the mantissa corresponding to
53 the integer nearest to Y, within the direction rnd, and returns the
54 exponent in exp.
55 n is the number of limbs of r.
56 e represents the maximal error in the approximation of Y
57 (e < 0 iff the approximation is exact, i.e. r*2^f = Y).
58 b is the wanted base (2 <= b <= 36).
59 m is the number of wanted digits in the mantissa.
60 rnd is the rounding mode.
61 It is assumed that b^(m-1) <= Y < b^(m+1), thus the returned value
62 satisfies b^(m-1) <= rnd(Y) < b^(m+1).
64 Rounding may fail for two reasons:
65 - the error is too large to determine the integer N nearest to Y
66 - either the number of digits of N in base b is too large (m+1),
67 N=2*N1+(b/2) and the rounding mode is to nearest. This can
68 only happen when b is even.
70 Return value:
71 - the direction of rounding (-1, 0, 1) if rounding is possible
72 - -MPFR_ROUND_FAILED if rounding not possible because m+1 digits
73 - MPFR_ROUND_FAILED otherwise (too large error)
75 static int
76 mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r,
77 mp_size_t n, mp_exp_t f, long e, int b, size_t m,
78 mp_rnd_t rnd)
80 int dir; /* direction of the rounded result */
81 mp_limb_t ret = 0; /* possible carry in addition */
82 mp_size_t i0, j0; /* number of limbs and bits of Y */
83 unsigned char *str1; /* string of m+2 characters */
84 size_t size_s1; /* length of str1 */
85 mp_rnd_t rnd1;
86 size_t i;
87 int exact = (e < 0);
88 MPFR_TMP_DECL(marker);
90 /* if f > 0, then the maximal error 2^(e+f) is larger than 2 so we can't
91 determine the integer Y */
92 MPFR_ASSERTN(f <= 0);
93 /* if f is too small, then r*2^f is smaller than 1 */
94 MPFR_ASSERTN(f > (-n * BITS_PER_MP_LIMB));
96 MPFR_TMP_MARK(marker);
98 /* R = 2^f sum r[i]K^(i)
99 r[i] = (r_(i,k-1)...r_(i,0))_2
100 R = sum r(i,j)2^(j+ki+f)
101 the bits from R are referenced by pairs (i,j) */
103 /* check if is possible to round r with rnd mode
104 where |r*2^f-Y| <= 2^(e+f)
105 the exponent of R is: f + n*BITS_PER_MP_LIMB
106 we must have e + f == f + n*BITS_PER_MP_LIMB - err
107 err = n*BITS_PER_MP_LIMB - e
108 R contains exactly -f bits after the integer point:
109 to determine the nearest integer, we thus need a precision of
110 n * BITS_PER_MP_LIMB + f */
112 if (exact || mpfr_can_round_raw (r, n, (mp_size_t) 1,
113 n * BITS_PER_MP_LIMB - e, GMP_RNDN, rnd, n * BITS_PER_MP_LIMB + f))
115 /* compute the nearest integer to R */
117 /* bit of weight 0 in R has position j0 in limb r[i0] */
118 i0 = (-f) / BITS_PER_MP_LIMB;
119 j0 = (-f) % BITS_PER_MP_LIMB;
121 ret = mpfr_round_raw (r + i0, r, n * BITS_PER_MP_LIMB, 0,
122 n * BITS_PER_MP_LIMB + f, rnd, &dir);
123 MPFR_ASSERTD(dir != MPFR_ROUND_FAILED);
125 /* warning: mpfr_round_raw_generic returns MPFR_EVEN_INEX (2) or
126 -MPFR_EVEN_INEX (-2) in case of even rounding */
128 if (ret) /* Y is a power of 2 */
130 if (j0)
131 r[n - 1] = MPFR_LIMB_HIGHBIT >> (j0 - 1);
132 else /* j0=0, necessarily i0 >= 1 otherwise f=0 and r is exact */
134 r[n - 1] = ret;
135 r[--i0] = 0; /* set to zero the new low limb */
138 else /* shift r to the right by (-f) bits (i0 already done) */
140 if (j0)
141 mpn_rshift (r + i0, r + i0, n - i0, j0);
144 /* now the rounded value Y is in {r+i0, n-i0} */
146 /* convert r+i0 into base b */
147 str1 = (unsigned char*) MPFR_TMP_ALLOC (m + 3); /* need one extra character for mpn_get_str */
148 size_s1 = mpn_get_str (str1, b, r + i0, n - i0);
150 /* round str1 */
151 MPFR_ASSERTN(size_s1 >= m);
152 *exp = size_s1 - m; /* number of superfluous characters */
154 /* if size_s1 = m + 2, necessarily we have b^(m+1) as result,
155 and the result will not change */
157 /* so we have to double-round only when size_s1 = m + 1 and
158 (i) the result is inexact
159 (ii) or the last digit is non-zero */
160 if ((size_s1 == m + 1) && ((dir != 0) || (str1[size_s1 - 1] != 0)))
162 /* rounding mode */
163 rnd1 = rnd;
165 /* round to nearest case */
166 if (rnd == GMP_RNDN)
168 if (2 * str1[size_s1 - 1] == b)
170 if (dir == 0 && exact) /* exact: even rounding */
172 rnd1 = ((str1[size_s1-2] & 1) == 0)
173 ? GMP_RNDD : GMP_RNDU;
175 else
177 /* otherwise we cannot round correctly: for example
178 if b=10, we might have a mantissa of
179 xxxxxxx5.00000000 which can be rounded to nearest
180 to 8 digits but not to 7 */
181 dir = -MPFR_ROUND_FAILED;
182 MPFR_ASSERTD(dir != MPFR_EVEN_INEX);
183 goto free_and_return;
186 else if (2 * str1[size_s1 - 1] < b)
187 rnd1 = GMP_RNDD;
188 else
189 rnd1 = GMP_RNDU;
192 /* now rnd1 is either GMP_RNDD or GMP_RNDZ -> truncate
193 or GMP_RDNU -> round towards infinity */
195 /* round away from zero */
196 if (rnd1 == GMP_RNDU)
198 if (str1[size_s1 - 1] != 0)
200 /* the carry cannot propagate to the whole string, since
201 Y = x*b^(m-g) < 2*b^m <= b^(m+1)-b
202 where x is the input float */
203 MPFR_ASSERTN(size_s1 >= 2);
204 i = size_s1 - 2;
205 while (str1[i] == b - 1)
207 MPFR_ASSERTD(i > 0);
208 str1[i--] = 0;
210 str1[i]++;
212 dir = 1;
214 /* round toward zero (truncate) */
215 else
216 dir = -1;
219 /* copy str1 into str and convert to characters (digits and
220 lowercase letters from the source character set) */
221 for (i = 0; i < m; i++)
222 str[i] = num_to_text[(int) str1[i]]; /* str1[i] is an unsigned char */
223 str[m] = 0;
225 /* mpfr_can_round_raw failed: rounding is not possible */
226 else
228 dir = MPFR_ROUND_FAILED; /* should be different from MPFR_EVEN_INEX */
229 MPFR_ASSERTD(dir != MPFR_EVEN_INEX);
232 free_and_return:
233 MPFR_TMP_FREE(marker);
235 return dir;
238 /***************************************************************************
239 * __gmpfr_l2b[b-2][0] is a 23-bit upper approximation to log(b)/log(2), *
240 * __gmpfr_l2b[b-2][1] is a 76-bit upper approximation to log(2)/log(b). *
241 * The following code is generated by tests/tl2b (with an argument). *
242 ***************************************************************************/
244 #if 0
245 #elif BITS_PER_MP_LIMB == 16
246 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x0000, 0x8000 };
247 #elif BITS_PER_MP_LIMB == 32
248 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x80000000 };
249 #elif BITS_PER_MP_LIMB == 64
250 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x8000000000000000 };
251 #elif BITS_PER_MP_LIMB == 96
252 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x800000000000000000000000 };
253 #elif BITS_PER_MP_LIMB == 128
254 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x80000000000000000000000000000000 };
255 #elif BITS_PER_MP_LIMB == 256
256 const mp_limb_t mpfr_l2b_2_0__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
257 #endif
259 #if 0
260 #elif BITS_PER_MP_LIMB == 16
261 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x8000 };
262 #elif BITS_PER_MP_LIMB == 32
263 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x00000000, 0x00000000, 0x80000000 };
264 #elif BITS_PER_MP_LIMB == 64
265 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x0000000000000000, 0x8000000000000000 };
266 #elif BITS_PER_MP_LIMB == 96
267 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x800000000000000000000000 };
268 #elif BITS_PER_MP_LIMB == 128
269 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x80000000000000000000000000000000 };
270 #elif BITS_PER_MP_LIMB == 256
271 const mp_limb_t mpfr_l2b_2_1__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
272 #endif
274 #if 0
275 #elif BITS_PER_MP_LIMB == 16
276 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0x0e00, 0xcae0 };
277 #elif BITS_PER_MP_LIMB == 32
278 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e00 };
279 #elif BITS_PER_MP_LIMB == 64
280 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e0000000000 };
281 #elif BITS_PER_MP_LIMB == 96
282 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e000000000000000000 };
283 #elif BITS_PER_MP_LIMB == 128
284 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e00000000000000000000000000 };
285 #elif BITS_PER_MP_LIMB == 256
286 const mp_limb_t mpfr_l2b_3_0__tab[] = { 0xcae00e0000000000000000000000000000000000000000000000000000000000 };
287 #endif
289 #if 0
290 #elif BITS_PER_MP_LIMB == 16
291 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0x0448, 0xe94e, 0xa9a9, 0x9cc1, 0xa184 };
292 #elif BITS_PER_MP_LIMB == 32
293 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0x04480000, 0xa9a9e94e, 0xa1849cc1 };
294 #elif BITS_PER_MP_LIMB == 64
295 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0x0448000000000000, 0xa1849cc1a9a9e94e };
296 #elif BITS_PER_MP_LIMB == 96
297 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0xa1849cc1a9a9e94e04480000 };
298 #elif BITS_PER_MP_LIMB == 128
299 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0xa1849cc1a9a9e94e0448000000000000 };
300 #elif BITS_PER_MP_LIMB == 256
301 const mp_limb_t mpfr_l2b_3_1__tab[] = { 0xa1849cc1a9a9e94e044800000000000000000000000000000000000000000000 };
302 #endif
304 #if 0
305 #elif BITS_PER_MP_LIMB == 16
306 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x0000, 0x8000 };
307 #elif BITS_PER_MP_LIMB == 32
308 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x80000000 };
309 #elif BITS_PER_MP_LIMB == 64
310 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x8000000000000000 };
311 #elif BITS_PER_MP_LIMB == 96
312 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x800000000000000000000000 };
313 #elif BITS_PER_MP_LIMB == 128
314 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x80000000000000000000000000000000 };
315 #elif BITS_PER_MP_LIMB == 256
316 const mp_limb_t mpfr_l2b_4_0__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
317 #endif
319 #if 0
320 #elif BITS_PER_MP_LIMB == 16
321 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x8000 };
322 #elif BITS_PER_MP_LIMB == 32
323 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x00000000, 0x00000000, 0x80000000 };
324 #elif BITS_PER_MP_LIMB == 64
325 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x0000000000000000, 0x8000000000000000 };
326 #elif BITS_PER_MP_LIMB == 96
327 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x800000000000000000000000 };
328 #elif BITS_PER_MP_LIMB == 128
329 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x80000000000000000000000000000000 };
330 #elif BITS_PER_MP_LIMB == 256
331 const mp_limb_t mpfr_l2b_4_1__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
332 #endif
334 #if 0
335 #elif BITS_PER_MP_LIMB == 16
336 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x7a00, 0x949a };
337 #elif BITS_PER_MP_LIMB == 32
338 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a00 };
339 #elif BITS_PER_MP_LIMB == 64
340 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a0000000000 };
341 #elif BITS_PER_MP_LIMB == 96
342 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a000000000000000000 };
343 #elif BITS_PER_MP_LIMB == 128
344 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a00000000000000000000000000 };
345 #elif BITS_PER_MP_LIMB == 256
346 const mp_limb_t mpfr_l2b_5_0__tab[] = { 0x949a7a0000000000000000000000000000000000000000000000000000000000 };
347 #endif
349 #if 0
350 #elif BITS_PER_MP_LIMB == 16
351 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0x67b8, 0x9728, 0x287b, 0xa348, 0xdc81 };
352 #elif BITS_PER_MP_LIMB == 32
353 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0x67b80000, 0x287b9728, 0xdc81a348 };
354 #elif BITS_PER_MP_LIMB == 64
355 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0x67b8000000000000, 0xdc81a348287b9728 };
356 #elif BITS_PER_MP_LIMB == 96
357 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0xdc81a348287b972867b80000 };
358 #elif BITS_PER_MP_LIMB == 128
359 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0xdc81a348287b972867b8000000000000 };
360 #elif BITS_PER_MP_LIMB == 256
361 const mp_limb_t mpfr_l2b_5_1__tab[] = { 0xdc81a348287b972867b800000000000000000000000000000000000000000000 };
362 #endif
364 #if 0
365 #elif BITS_PER_MP_LIMB == 16
366 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0x0800, 0xa570 };
367 #elif BITS_PER_MP_LIMB == 32
368 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa5700800 };
369 #elif BITS_PER_MP_LIMB == 64
370 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa570080000000000 };
371 #elif BITS_PER_MP_LIMB == 96
372 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa57008000000000000000000 };
373 #elif BITS_PER_MP_LIMB == 128
374 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa5700800000000000000000000000000 };
375 #elif BITS_PER_MP_LIMB == 256
376 const mp_limb_t mpfr_l2b_6_0__tab[] = { 0xa570080000000000000000000000000000000000000000000000000000000000 };
377 #endif
379 #if 0
380 #elif BITS_PER_MP_LIMB == 16
381 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xff10, 0xf9e9, 0xe054, 0x9236, 0xc611 };
382 #elif BITS_PER_MP_LIMB == 32
383 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xff100000, 0xe054f9e9, 0xc6119236 };
384 #elif BITS_PER_MP_LIMB == 64
385 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xff10000000000000, 0xc6119236e054f9e9 };
386 #elif BITS_PER_MP_LIMB == 96
387 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xc6119236e054f9e9ff100000 };
388 #elif BITS_PER_MP_LIMB == 128
389 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xc6119236e054f9e9ff10000000000000 };
390 #elif BITS_PER_MP_LIMB == 256
391 const mp_limb_t mpfr_l2b_6_1__tab[] = { 0xc6119236e054f9e9ff1000000000000000000000000000000000000000000000 };
392 #endif
394 #if 0
395 #elif BITS_PER_MP_LIMB == 16
396 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb400, 0xb3ab };
397 #elif BITS_PER_MP_LIMB == 32
398 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb400 };
399 #elif BITS_PER_MP_LIMB == 64
400 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb40000000000 };
401 #elif BITS_PER_MP_LIMB == 96
402 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb4000000000000000000 };
403 #elif BITS_PER_MP_LIMB == 128
404 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb400000000000000000000000000 };
405 #elif BITS_PER_MP_LIMB == 256
406 const mp_limb_t mpfr_l2b_7_0__tab[] = { 0xb3abb40000000000000000000000000000000000000000000000000000000000 };
407 #endif
409 #if 0
410 #elif BITS_PER_MP_LIMB == 16
411 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0x37b8, 0xa711, 0x754d, 0xc9d6, 0xb660 };
412 #elif BITS_PER_MP_LIMB == 32
413 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0x37b80000, 0x754da711, 0xb660c9d6 };
414 #elif BITS_PER_MP_LIMB == 64
415 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0x37b8000000000000, 0xb660c9d6754da711 };
416 #elif BITS_PER_MP_LIMB == 96
417 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0xb660c9d6754da71137b80000 };
418 #elif BITS_PER_MP_LIMB == 128
419 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0xb660c9d6754da71137b8000000000000 };
420 #elif BITS_PER_MP_LIMB == 256
421 const mp_limb_t mpfr_l2b_7_1__tab[] = { 0xb660c9d6754da71137b800000000000000000000000000000000000000000000 };
422 #endif
424 #if 0
425 #elif BITS_PER_MP_LIMB == 16
426 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0x0000, 0xc000 };
427 #elif BITS_PER_MP_LIMB == 32
428 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc0000000 };
429 #elif BITS_PER_MP_LIMB == 64
430 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc000000000000000 };
431 #elif BITS_PER_MP_LIMB == 96
432 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc00000000000000000000000 };
433 #elif BITS_PER_MP_LIMB == 128
434 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc0000000000000000000000000000000 };
435 #elif BITS_PER_MP_LIMB == 256
436 const mp_limb_t mpfr_l2b_8_0__tab[] = { 0xc000000000000000000000000000000000000000000000000000000000000000 };
437 #endif
439 #if 0
440 #elif BITS_PER_MP_LIMB == 16
441 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaab0, 0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa };
442 #elif BITS_PER_MP_LIMB == 32
443 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaab00000, 0xaaaaaaaa, 0xaaaaaaaa };
444 #elif BITS_PER_MP_LIMB == 64
445 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaab0000000000000, 0xaaaaaaaaaaaaaaaa };
446 #elif BITS_PER_MP_LIMB == 96
447 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaaaaaaaaaaaaaaaaaab00000 };
448 #elif BITS_PER_MP_LIMB == 128
449 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaaaaaaaaaaaaaaaaaab0000000000000 };
450 #elif BITS_PER_MP_LIMB == 256
451 const mp_limb_t mpfr_l2b_8_1__tab[] = { 0xaaaaaaaaaaaaaaaaaab000000000000000000000000000000000000000000000 };
452 #endif
454 #if 0
455 #elif BITS_PER_MP_LIMB == 16
456 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0x0e00, 0xcae0 };
457 #elif BITS_PER_MP_LIMB == 32
458 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e00 };
459 #elif BITS_PER_MP_LIMB == 64
460 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e0000000000 };
461 #elif BITS_PER_MP_LIMB == 96
462 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e000000000000000000 };
463 #elif BITS_PER_MP_LIMB == 128
464 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e00000000000000000000000000 };
465 #elif BITS_PER_MP_LIMB == 256
466 const mp_limb_t mpfr_l2b_9_0__tab[] = { 0xcae00e0000000000000000000000000000000000000000000000000000000000 };
467 #endif
469 #if 0
470 #elif BITS_PER_MP_LIMB == 16
471 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0x0448, 0xe94e, 0xa9a9, 0x9cc1, 0xa184 };
472 #elif BITS_PER_MP_LIMB == 32
473 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0x04480000, 0xa9a9e94e, 0xa1849cc1 };
474 #elif BITS_PER_MP_LIMB == 64
475 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0x0448000000000000, 0xa1849cc1a9a9e94e };
476 #elif BITS_PER_MP_LIMB == 96
477 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0xa1849cc1a9a9e94e04480000 };
478 #elif BITS_PER_MP_LIMB == 128
479 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0xa1849cc1a9a9e94e0448000000000000 };
480 #elif BITS_PER_MP_LIMB == 256
481 const mp_limb_t mpfr_l2b_9_1__tab[] = { 0xa1849cc1a9a9e94e044800000000000000000000000000000000000000000000 };
482 #endif
484 #if 0
485 #elif BITS_PER_MP_LIMB == 16
486 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0x7a00, 0xd49a };
487 #elif BITS_PER_MP_LIMB == 32
488 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a00 };
489 #elif BITS_PER_MP_LIMB == 64
490 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a0000000000 };
491 #elif BITS_PER_MP_LIMB == 96
492 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a000000000000000000 };
493 #elif BITS_PER_MP_LIMB == 128
494 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a00000000000000000000000000 };
495 #elif BITS_PER_MP_LIMB == 256
496 const mp_limb_t mpfr_l2b_10_0__tab[] = { 0xd49a7a0000000000000000000000000000000000000000000000000000000000 };
497 #endif
499 #if 0
500 #elif BITS_PER_MP_LIMB == 16
501 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x8f90, 0xf798, 0xfbcf, 0x9a84, 0x9a20 };
502 #elif BITS_PER_MP_LIMB == 32
503 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x8f900000, 0xfbcff798, 0x9a209a84 };
504 #elif BITS_PER_MP_LIMB == 64
505 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x8f90000000000000, 0x9a209a84fbcff798 };
506 #elif BITS_PER_MP_LIMB == 96
507 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x9a209a84fbcff7988f900000 };
508 #elif BITS_PER_MP_LIMB == 128
509 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x9a209a84fbcff7988f90000000000000 };
510 #elif BITS_PER_MP_LIMB == 256
511 const mp_limb_t mpfr_l2b_10_1__tab[] = { 0x9a209a84fbcff7988f9000000000000000000000000000000000000000000000 };
512 #endif
514 #if 0
515 #elif BITS_PER_MP_LIMB == 16
516 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0x5400, 0xdd67 };
517 #elif BITS_PER_MP_LIMB == 32
518 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd675400 };
519 #elif BITS_PER_MP_LIMB == 64
520 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd67540000000000 };
521 #elif BITS_PER_MP_LIMB == 96
522 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd6754000000000000000000 };
523 #elif BITS_PER_MP_LIMB == 128
524 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd675400000000000000000000000000 };
525 #elif BITS_PER_MP_LIMB == 256
526 const mp_limb_t mpfr_l2b_11_0__tab[] = { 0xdd67540000000000000000000000000000000000000000000000000000000000 };
527 #endif
529 #if 0
530 #elif BITS_PER_MP_LIMB == 16
531 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0xe170, 0x9d10, 0xeb22, 0x4e0e, 0x9400 };
532 #elif BITS_PER_MP_LIMB == 32
533 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0xe1700000, 0xeb229d10, 0x94004e0e };
534 #elif BITS_PER_MP_LIMB == 64
535 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0xe170000000000000, 0x94004e0eeb229d10 };
536 #elif BITS_PER_MP_LIMB == 96
537 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0x94004e0eeb229d10e1700000 };
538 #elif BITS_PER_MP_LIMB == 128
539 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0x94004e0eeb229d10e170000000000000 };
540 #elif BITS_PER_MP_LIMB == 256
541 const mp_limb_t mpfr_l2b_11_1__tab[] = { 0x94004e0eeb229d10e17000000000000000000000000000000000000000000000 };
542 #endif
544 #if 0
545 #elif BITS_PER_MP_LIMB == 16
546 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0x0800, 0xe570 };
547 #elif BITS_PER_MP_LIMB == 32
548 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe5700800 };
549 #elif BITS_PER_MP_LIMB == 64
550 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe570080000000000 };
551 #elif BITS_PER_MP_LIMB == 96
552 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe57008000000000000000000 };
553 #elif BITS_PER_MP_LIMB == 128
554 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe5700800000000000000000000000000 };
555 #elif BITS_PER_MP_LIMB == 256
556 const mp_limb_t mpfr_l2b_12_0__tab[] = { 0xe570080000000000000000000000000000000000000000000000000000000000 };
557 #endif
559 #if 0
560 #elif BITS_PER_MP_LIMB == 16
561 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0xfe28, 0x1c24, 0x0b03, 0x9c1a, 0x8ed1 };
562 #elif BITS_PER_MP_LIMB == 32
563 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0xfe280000, 0x0b031c24, 0x8ed19c1a };
564 #elif BITS_PER_MP_LIMB == 64
565 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0xfe28000000000000, 0x8ed19c1a0b031c24 };
566 #elif BITS_PER_MP_LIMB == 96
567 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0x8ed19c1a0b031c24fe280000 };
568 #elif BITS_PER_MP_LIMB == 128
569 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0x8ed19c1a0b031c24fe28000000000000 };
570 #elif BITS_PER_MP_LIMB == 256
571 const mp_limb_t mpfr_l2b_12_1__tab[] = { 0x8ed19c1a0b031c24fe2800000000000000000000000000000000000000000000 };
572 #endif
574 #if 0
575 #elif BITS_PER_MP_LIMB == 16
576 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0x0200, 0xecd4 };
577 #elif BITS_PER_MP_LIMB == 32
578 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd40200 };
579 #elif BITS_PER_MP_LIMB == 64
580 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd4020000000000 };
581 #elif BITS_PER_MP_LIMB == 96
582 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd402000000000000000000 };
583 #elif BITS_PER_MP_LIMB == 128
584 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd40200000000000000000000000000 };
585 #elif BITS_PER_MP_LIMB == 256
586 const mp_limb_t mpfr_l2b_13_0__tab[] = { 0xecd4020000000000000000000000000000000000000000000000000000000000 };
587 #endif
589 #if 0
590 #elif BITS_PER_MP_LIMB == 16
591 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x57f8, 0xf7b4, 0xcb20, 0xa7c6, 0x8a5c };
592 #elif BITS_PER_MP_LIMB == 32
593 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x57f80000, 0xcb20f7b4, 0x8a5ca7c6 };
594 #elif BITS_PER_MP_LIMB == 64
595 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x57f8000000000000, 0x8a5ca7c6cb20f7b4 };
596 #elif BITS_PER_MP_LIMB == 96
597 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x8a5ca7c6cb20f7b457f80000 };
598 #elif BITS_PER_MP_LIMB == 128
599 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x8a5ca7c6cb20f7b457f8000000000000 };
600 #elif BITS_PER_MP_LIMB == 256
601 const mp_limb_t mpfr_l2b_13_1__tab[] = { 0x8a5ca7c6cb20f7b457f800000000000000000000000000000000000000000000 };
602 #endif
604 #if 0
605 #elif BITS_PER_MP_LIMB == 16
606 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xb400, 0xf3ab };
607 #elif BITS_PER_MP_LIMB == 32
608 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb400 };
609 #elif BITS_PER_MP_LIMB == 64
610 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb40000000000 };
611 #elif BITS_PER_MP_LIMB == 96
612 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb4000000000000000000 };
613 #elif BITS_PER_MP_LIMB == 128
614 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb400000000000000000000000000 };
615 #elif BITS_PER_MP_LIMB == 256
616 const mp_limb_t mpfr_l2b_14_0__tab[] = { 0xf3abb40000000000000000000000000000000000000000000000000000000000 };
617 #endif
619 #if 0
620 #elif BITS_PER_MP_LIMB == 16
621 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x85a8, 0x5cab, 0x96b5, 0xfff6, 0x8679 };
622 #elif BITS_PER_MP_LIMB == 32
623 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x85a80000, 0x96b55cab, 0x8679fff6 };
624 #elif BITS_PER_MP_LIMB == 64
625 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x85a8000000000000, 0x8679fff696b55cab };
626 #elif BITS_PER_MP_LIMB == 96
627 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x8679fff696b55cab85a80000 };
628 #elif BITS_PER_MP_LIMB == 128
629 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x8679fff696b55cab85a8000000000000 };
630 #elif BITS_PER_MP_LIMB == 256
631 const mp_limb_t mpfr_l2b_14_1__tab[] = { 0x8679fff696b55cab85a800000000000000000000000000000000000000000000 };
632 #endif
634 #if 0
635 #elif BITS_PER_MP_LIMB == 16
636 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0x8000, 0xfa0a };
637 #elif BITS_PER_MP_LIMB == 32
638 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a8000 };
639 #elif BITS_PER_MP_LIMB == 64
640 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a800000000000 };
641 #elif BITS_PER_MP_LIMB == 96
642 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a80000000000000000000 };
643 #elif BITS_PER_MP_LIMB == 128
644 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a8000000000000000000000000000 };
645 #elif BITS_PER_MP_LIMB == 256
646 const mp_limb_t mpfr_l2b_15_0__tab[] = { 0xfa0a800000000000000000000000000000000000000000000000000000000000 };
647 #endif
649 #if 0
650 #elif BITS_PER_MP_LIMB == 16
651 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x6f80, 0xa6aa, 0x69f0, 0xee23, 0x830c };
652 #elif BITS_PER_MP_LIMB == 32
653 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x6f800000, 0x69f0a6aa, 0x830cee23 };
654 #elif BITS_PER_MP_LIMB == 64
655 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x6f80000000000000, 0x830cee2369f0a6aa };
656 #elif BITS_PER_MP_LIMB == 96
657 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x830cee2369f0a6aa6f800000 };
658 #elif BITS_PER_MP_LIMB == 128
659 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x830cee2369f0a6aa6f80000000000000 };
660 #elif BITS_PER_MP_LIMB == 256
661 const mp_limb_t mpfr_l2b_15_1__tab[] = { 0x830cee2369f0a6aa6f8000000000000000000000000000000000000000000000 };
662 #endif
664 #if 0
665 #elif BITS_PER_MP_LIMB == 16
666 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x0000, 0x8000 };
667 #elif BITS_PER_MP_LIMB == 32
668 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x80000000 };
669 #elif BITS_PER_MP_LIMB == 64
670 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x8000000000000000 };
671 #elif BITS_PER_MP_LIMB == 96
672 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x800000000000000000000000 };
673 #elif BITS_PER_MP_LIMB == 128
674 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x80000000000000000000000000000000 };
675 #elif BITS_PER_MP_LIMB == 256
676 const mp_limb_t mpfr_l2b_16_0__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
677 #endif
679 #if 0
680 #elif BITS_PER_MP_LIMB == 16
681 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x8000 };
682 #elif BITS_PER_MP_LIMB == 32
683 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x00000000, 0x00000000, 0x80000000 };
684 #elif BITS_PER_MP_LIMB == 64
685 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x0000000000000000, 0x8000000000000000 };
686 #elif BITS_PER_MP_LIMB == 96
687 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x800000000000000000000000 };
688 #elif BITS_PER_MP_LIMB == 128
689 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x80000000000000000000000000000000 };
690 #elif BITS_PER_MP_LIMB == 256
691 const mp_limb_t mpfr_l2b_16_1__tab[] = { 0x8000000000000000000000000000000000000000000000000000000000000000 };
692 #endif
694 #if 0
695 #elif BITS_PER_MP_LIMB == 16
696 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x8000, 0x82cc };
697 #elif BITS_PER_MP_LIMB == 32
698 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc8000 };
699 #elif BITS_PER_MP_LIMB == 64
700 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc800000000000 };
701 #elif BITS_PER_MP_LIMB == 96
702 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc80000000000000000000 };
703 #elif BITS_PER_MP_LIMB == 128
704 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc8000000000000000000000000000 };
705 #elif BITS_PER_MP_LIMB == 256
706 const mp_limb_t mpfr_l2b_17_0__tab[] = { 0x82cc800000000000000000000000000000000000000000000000000000000000 };
707 #endif
709 #if 0
710 #elif BITS_PER_MP_LIMB == 16
711 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0x8720, 0x259b, 0x62c4, 0xabf5, 0xfa85 };
712 #elif BITS_PER_MP_LIMB == 32
713 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0x87200000, 0x62c4259b, 0xfa85abf5 };
714 #elif BITS_PER_MP_LIMB == 64
715 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0x8720000000000000, 0xfa85abf562c4259b };
716 #elif BITS_PER_MP_LIMB == 96
717 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0xfa85abf562c4259b87200000 };
718 #elif BITS_PER_MP_LIMB == 128
719 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0xfa85abf562c4259b8720000000000000 };
720 #elif BITS_PER_MP_LIMB == 256
721 const mp_limb_t mpfr_l2b_17_1__tab[] = { 0xfa85abf562c4259b872000000000000000000000000000000000000000000000 };
722 #endif
724 #if 0
725 #elif BITS_PER_MP_LIMB == 16
726 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x0800, 0x8570 };
727 #elif BITS_PER_MP_LIMB == 32
728 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x85700800 };
729 #elif BITS_PER_MP_LIMB == 64
730 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x8570080000000000 };
731 #elif BITS_PER_MP_LIMB == 96
732 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x857008000000000000000000 };
733 #elif BITS_PER_MP_LIMB == 128
734 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x85700800000000000000000000000000 };
735 #elif BITS_PER_MP_LIMB == 256
736 const mp_limb_t mpfr_l2b_18_0__tab[] = { 0x8570080000000000000000000000000000000000000000000000000000000000 };
737 #endif
739 #if 0
740 #elif BITS_PER_MP_LIMB == 16
741 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0x3698, 0x1378, 0x5537, 0x6634, 0xf591 };
742 #elif BITS_PER_MP_LIMB == 32
743 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0x36980000, 0x55371378, 0xf5916634 };
744 #elif BITS_PER_MP_LIMB == 64
745 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0x3698000000000000, 0xf591663455371378 };
746 #elif BITS_PER_MP_LIMB == 96
747 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0xf59166345537137836980000 };
748 #elif BITS_PER_MP_LIMB == 128
749 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0xf5916634553713783698000000000000 };
750 #elif BITS_PER_MP_LIMB == 256
751 const mp_limb_t mpfr_l2b_18_1__tab[] = { 0xf591663455371378369800000000000000000000000000000000000000000000 };
752 #endif
754 #if 0
755 #elif BITS_PER_MP_LIMB == 16
756 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x0600, 0x87ef };
757 #elif BITS_PER_MP_LIMB == 32
758 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef0600 };
759 #elif BITS_PER_MP_LIMB == 64
760 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef060000000000 };
761 #elif BITS_PER_MP_LIMB == 96
762 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef06000000000000000000 };
763 #elif BITS_PER_MP_LIMB == 128
764 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef0600000000000000000000000000 };
765 #elif BITS_PER_MP_LIMB == 256
766 const mp_limb_t mpfr_l2b_19_0__tab[] = { 0x87ef060000000000000000000000000000000000000000000000000000000000 };
767 #endif
769 #if 0
770 #elif BITS_PER_MP_LIMB == 16
771 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0x0db8, 0x558c, 0x62ed, 0x08c0, 0xf10f };
772 #elif BITS_PER_MP_LIMB == 32
773 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0x0db80000, 0x62ed558c, 0xf10f08c0 };
774 #elif BITS_PER_MP_LIMB == 64
775 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0x0db8000000000000, 0xf10f08c062ed558c };
776 #elif BITS_PER_MP_LIMB == 96
777 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0xf10f08c062ed558c0db80000 };
778 #elif BITS_PER_MP_LIMB == 128
779 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0xf10f08c062ed558c0db8000000000000 };
780 #elif BITS_PER_MP_LIMB == 256
781 const mp_limb_t mpfr_l2b_19_1__tab[] = { 0xf10f08c062ed558c0db800000000000000000000000000000000000000000000 };
782 #endif
784 #if 0
785 #elif BITS_PER_MP_LIMB == 16
786 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x3e00, 0x8a4d };
787 #elif BITS_PER_MP_LIMB == 32
788 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e00 };
789 #elif BITS_PER_MP_LIMB == 64
790 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e0000000000 };
791 #elif BITS_PER_MP_LIMB == 96
792 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e000000000000000000 };
793 #elif BITS_PER_MP_LIMB == 128
794 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e00000000000000000000000000 };
795 #elif BITS_PER_MP_LIMB == 256
796 const mp_limb_t mpfr_l2b_20_0__tab[] = { 0x8a4d3e0000000000000000000000000000000000000000000000000000000000 };
797 #endif
799 #if 0
800 #elif BITS_PER_MP_LIMB == 16
801 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0x0b40, 0xa71c, 0x1cc1, 0x690a, 0xecee };
802 #elif BITS_PER_MP_LIMB == 32
803 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0x0b400000, 0x1cc1a71c, 0xecee690a };
804 #elif BITS_PER_MP_LIMB == 64
805 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0x0b40000000000000, 0xecee690a1cc1a71c };
806 #elif BITS_PER_MP_LIMB == 96
807 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0xecee690a1cc1a71c0b400000 };
808 #elif BITS_PER_MP_LIMB == 128
809 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0xecee690a1cc1a71c0b40000000000000 };
810 #elif BITS_PER_MP_LIMB == 256
811 const mp_limb_t mpfr_l2b_20_1__tab[] = { 0xecee690a1cc1a71c0b4000000000000000000000000000000000000000000000 };
812 #endif
814 #if 0
815 #elif BITS_PER_MP_LIMB == 16
816 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0xde00, 0x8c8d };
817 #elif BITS_PER_MP_LIMB == 32
818 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde00 };
819 #elif BITS_PER_MP_LIMB == 64
820 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde0000000000 };
821 #elif BITS_PER_MP_LIMB == 96
822 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde000000000000000000 };
823 #elif BITS_PER_MP_LIMB == 128
824 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde00000000000000000000000000 };
825 #elif BITS_PER_MP_LIMB == 256
826 const mp_limb_t mpfr_l2b_21_0__tab[] = { 0x8c8dde0000000000000000000000000000000000000000000000000000000000 };
827 #endif
829 #if 0
830 #elif BITS_PER_MP_LIMB == 16
831 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0x4108, 0x6b26, 0xb3d0, 0x63c1, 0xe922 };
832 #elif BITS_PER_MP_LIMB == 32
833 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0x41080000, 0xb3d06b26, 0xe92263c1 };
834 #elif BITS_PER_MP_LIMB == 64
835 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0x4108000000000000, 0xe92263c1b3d06b26 };
836 #elif BITS_PER_MP_LIMB == 96
837 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0xe92263c1b3d06b2641080000 };
838 #elif BITS_PER_MP_LIMB == 128
839 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0xe92263c1b3d06b264108000000000000 };
840 #elif BITS_PER_MP_LIMB == 256
841 const mp_limb_t mpfr_l2b_21_1__tab[] = { 0xe92263c1b3d06b26410800000000000000000000000000000000000000000000 };
842 #endif
844 #if 0
845 #elif BITS_PER_MP_LIMB == 16
846 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0xaa00, 0x8eb3 };
847 #elif BITS_PER_MP_LIMB == 32
848 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa00 };
849 #elif BITS_PER_MP_LIMB == 64
850 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa0000000000 };
851 #elif BITS_PER_MP_LIMB == 96
852 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa000000000000000000 };
853 #elif BITS_PER_MP_LIMB == 128
854 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa00000000000000000000000000 };
855 #elif BITS_PER_MP_LIMB == 256
856 const mp_limb_t mpfr_l2b_22_0__tab[] = { 0x8eb3aa0000000000000000000000000000000000000000000000000000000000 };
857 #endif
859 #if 0
860 #elif BITS_PER_MP_LIMB == 16
861 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xdbe8, 0xf061, 0x60b9, 0x2c4d, 0xe5a0 };
862 #elif BITS_PER_MP_LIMB == 32
863 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xdbe80000, 0x60b9f061, 0xe5a02c4d };
864 #elif BITS_PER_MP_LIMB == 64
865 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xdbe8000000000000, 0xe5a02c4d60b9f061 };
866 #elif BITS_PER_MP_LIMB == 96
867 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xe5a02c4d60b9f061dbe80000 };
868 #elif BITS_PER_MP_LIMB == 128
869 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xe5a02c4d60b9f061dbe8000000000000 };
870 #elif BITS_PER_MP_LIMB == 256
871 const mp_limb_t mpfr_l2b_22_1__tab[] = { 0xe5a02c4d60b9f061dbe800000000000000000000000000000000000000000000 };
872 #endif
874 #if 0
875 #elif BITS_PER_MP_LIMB == 16
876 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x0600, 0x90c1 };
877 #elif BITS_PER_MP_LIMB == 32
878 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c10600 };
879 #elif BITS_PER_MP_LIMB == 64
880 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c1060000000000 };
881 #elif BITS_PER_MP_LIMB == 96
882 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c106000000000000000000 };
883 #elif BITS_PER_MP_LIMB == 128
884 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c10600000000000000000000000000 };
885 #elif BITS_PER_MP_LIMB == 256
886 const mp_limb_t mpfr_l2b_23_0__tab[] = { 0x90c1060000000000000000000000000000000000000000000000000000000000 };
887 #endif
889 #if 0
890 #elif BITS_PER_MP_LIMB == 16
891 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xc3e0, 0x586a, 0x46b9, 0xcadd, 0xe25e };
892 #elif BITS_PER_MP_LIMB == 32
893 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xc3e00000, 0x46b9586a, 0xe25ecadd };
894 #elif BITS_PER_MP_LIMB == 64
895 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xc3e0000000000000, 0xe25ecadd46b9586a };
896 #elif BITS_PER_MP_LIMB == 96
897 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xe25ecadd46b9586ac3e00000 };
898 #elif BITS_PER_MP_LIMB == 128
899 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xe25ecadd46b9586ac3e0000000000000 };
900 #elif BITS_PER_MP_LIMB == 256
901 const mp_limb_t mpfr_l2b_23_1__tab[] = { 0xe25ecadd46b9586ac3e000000000000000000000000000000000000000000000 };
902 #endif
904 #if 0
905 #elif BITS_PER_MP_LIMB == 16
906 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x0400, 0x92b8 };
907 #elif BITS_PER_MP_LIMB == 32
908 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b80400 };
909 #elif BITS_PER_MP_LIMB == 64
910 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b8040000000000 };
911 #elif BITS_PER_MP_LIMB == 96
912 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b804000000000000000000 };
913 #elif BITS_PER_MP_LIMB == 128
914 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b80400000000000000000000000000 };
915 #elif BITS_PER_MP_LIMB == 256
916 const mp_limb_t mpfr_l2b_24_0__tab[] = { 0x92b8040000000000000000000000000000000000000000000000000000000000 };
917 #endif
919 #if 0
920 #elif BITS_PER_MP_LIMB == 16
921 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0x3668, 0x7263, 0xc7c6, 0xbb44, 0xdf56 };
922 #elif BITS_PER_MP_LIMB == 32
923 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0x36680000, 0xc7c67263, 0xdf56bb44 };
924 #elif BITS_PER_MP_LIMB == 64
925 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0x3668000000000000, 0xdf56bb44c7c67263 };
926 #elif BITS_PER_MP_LIMB == 96
927 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0xdf56bb44c7c6726336680000 };
928 #elif BITS_PER_MP_LIMB == 128
929 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0xdf56bb44c7c672633668000000000000 };
930 #elif BITS_PER_MP_LIMB == 256
931 const mp_limb_t mpfr_l2b_24_1__tab[] = { 0xdf56bb44c7c67263366800000000000000000000000000000000000000000000 };
932 #endif
934 #if 0
935 #elif BITS_PER_MP_LIMB == 16
936 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x7a00, 0x949a };
937 #elif BITS_PER_MP_LIMB == 32
938 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a00 };
939 #elif BITS_PER_MP_LIMB == 64
940 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a0000000000 };
941 #elif BITS_PER_MP_LIMB == 96
942 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a000000000000000000 };
943 #elif BITS_PER_MP_LIMB == 128
944 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a00000000000000000000000000 };
945 #elif BITS_PER_MP_LIMB == 256
946 const mp_limb_t mpfr_l2b_25_0__tab[] = { 0x949a7a0000000000000000000000000000000000000000000000000000000000 };
947 #endif
949 #if 0
950 #elif BITS_PER_MP_LIMB == 16
951 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0x67b8, 0x9728, 0x287b, 0xa348, 0xdc81 };
952 #elif BITS_PER_MP_LIMB == 32
953 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0x67b80000, 0x287b9728, 0xdc81a348 };
954 #elif BITS_PER_MP_LIMB == 64
955 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0x67b8000000000000, 0xdc81a348287b9728 };
956 #elif BITS_PER_MP_LIMB == 96
957 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0xdc81a348287b972867b80000 };
958 #elif BITS_PER_MP_LIMB == 128
959 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0xdc81a348287b972867b8000000000000 };
960 #elif BITS_PER_MP_LIMB == 256
961 const mp_limb_t mpfr_l2b_25_1__tab[] = { 0xdc81a348287b972867b800000000000000000000000000000000000000000000 };
962 #endif
964 #if 0
965 #elif BITS_PER_MP_LIMB == 16
966 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x0200, 0x966a };
967 #elif BITS_PER_MP_LIMB == 32
968 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a0200 };
969 #elif BITS_PER_MP_LIMB == 64
970 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a020000000000 };
971 #elif BITS_PER_MP_LIMB == 96
972 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a02000000000000000000 };
973 #elif BITS_PER_MP_LIMB == 128
974 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a0200000000000000000000000000 };
975 #elif BITS_PER_MP_LIMB == 256
976 const mp_limb_t mpfr_l2b_26_0__tab[] = { 0x966a020000000000000000000000000000000000000000000000000000000000 };
977 #endif
979 #if 0
980 #elif BITS_PER_MP_LIMB == 16
981 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0x6458, 0x78a4, 0x7583, 0x19f9, 0xd9da };
982 #elif BITS_PER_MP_LIMB == 32
983 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0x64580000, 0x758378a4, 0xd9da19f9 };
984 #elif BITS_PER_MP_LIMB == 64
985 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0x6458000000000000, 0xd9da19f9758378a4 };
986 #elif BITS_PER_MP_LIMB == 96
987 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0xd9da19f9758378a464580000 };
988 #elif BITS_PER_MP_LIMB == 128
989 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0xd9da19f9758378a46458000000000000 };
990 #elif BITS_PER_MP_LIMB == 256
991 const mp_limb_t mpfr_l2b_26_1__tab[] = { 0xd9da19f9758378a4645800000000000000000000000000000000000000000000 };
992 #endif
994 #if 0
995 #elif BITS_PER_MP_LIMB == 16
996 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x0a00, 0x9828 };
997 #elif BITS_PER_MP_LIMB == 32
998 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a00 };
999 #elif BITS_PER_MP_LIMB == 64
1000 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a0000000000 };
1001 #elif BITS_PER_MP_LIMB == 96
1002 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a000000000000000000 };
1003 #elif BITS_PER_MP_LIMB == 128
1004 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a00000000000000000000000000 };
1005 #elif BITS_PER_MP_LIMB == 256
1006 const mp_limb_t mpfr_l2b_27_0__tab[] = { 0x98280a0000000000000000000000000000000000000000000000000000000000 };
1007 #endif
1009 #if 0
1010 #elif BITS_PER_MP_LIMB == 16
1011 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0x5b08, 0xe1bd, 0xe237, 0x7bac, 0xd75b };
1012 #elif BITS_PER_MP_LIMB == 32
1013 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0x5b080000, 0xe237e1bd, 0xd75b7bac };
1014 #elif BITS_PER_MP_LIMB == 64
1015 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0x5b08000000000000, 0xd75b7bace237e1bd };
1016 #elif BITS_PER_MP_LIMB == 96
1017 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0xd75b7bace237e1bd5b080000 };
1018 #elif BITS_PER_MP_LIMB == 128
1019 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0xd75b7bace237e1bd5b08000000000000 };
1020 #elif BITS_PER_MP_LIMB == 256
1021 const mp_limb_t mpfr_l2b_27_1__tab[] = { 0xd75b7bace237e1bd5b0800000000000000000000000000000000000000000000 };
1022 #endif
1024 #if 0
1025 #elif BITS_PER_MP_LIMB == 16
1026 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0xda00, 0x99d5 };
1027 #elif BITS_PER_MP_LIMB == 32
1028 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da00 };
1029 #elif BITS_PER_MP_LIMB == 64
1030 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da0000000000 };
1031 #elif BITS_PER_MP_LIMB == 96
1032 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da000000000000000000 };
1033 #elif BITS_PER_MP_LIMB == 128
1034 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da00000000000000000000000000 };
1035 #elif BITS_PER_MP_LIMB == 256
1036 const mp_limb_t mpfr_l2b_28_0__tab[] = { 0x99d5da0000000000000000000000000000000000000000000000000000000000 };
1037 #endif
1039 #if 0
1040 #elif BITS_PER_MP_LIMB == 16
1041 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xdeb8, 0xe8b8, 0x71df, 0xc758, 0xd501 };
1042 #elif BITS_PER_MP_LIMB == 32
1043 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xdeb80000, 0x71dfe8b8, 0xd501c758 };
1044 #elif BITS_PER_MP_LIMB == 64
1045 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xdeb8000000000000, 0xd501c75871dfe8b8 };
1046 #elif BITS_PER_MP_LIMB == 96
1047 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xd501c75871dfe8b8deb80000 };
1048 #elif BITS_PER_MP_LIMB == 128
1049 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xd501c75871dfe8b8deb8000000000000 };
1050 #elif BITS_PER_MP_LIMB == 256
1051 const mp_limb_t mpfr_l2b_28_1__tab[] = { 0xd501c75871dfe8b8deb800000000000000000000000000000000000000000000 };
1052 #endif
1054 #if 0
1055 #elif BITS_PER_MP_LIMB == 16
1056 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9600, 0x9b74 };
1057 #elif BITS_PER_MP_LIMB == 32
1058 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b749600 };
1059 #elif BITS_PER_MP_LIMB == 64
1060 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b74960000000000 };
1061 #elif BITS_PER_MP_LIMB == 96
1062 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b7496000000000000000000 };
1063 #elif BITS_PER_MP_LIMB == 128
1064 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b749600000000000000000000000000 };
1065 #elif BITS_PER_MP_LIMB == 256
1066 const mp_limb_t mpfr_l2b_29_0__tab[] = { 0x9b74960000000000000000000000000000000000000000000000000000000000 };
1067 #endif
1069 #if 0
1070 #elif BITS_PER_MP_LIMB == 16
1071 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xccc8, 0x62b3, 0x9c6c, 0x8315, 0xd2c9 };
1072 #elif BITS_PER_MP_LIMB == 32
1073 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xccc80000, 0x9c6c62b3, 0xd2c98315 };
1074 #elif BITS_PER_MP_LIMB == 64
1075 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xccc8000000000000, 0xd2c983159c6c62b3 };
1076 #elif BITS_PER_MP_LIMB == 96
1077 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xd2c983159c6c62b3ccc80000 };
1078 #elif BITS_PER_MP_LIMB == 128
1079 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xd2c983159c6c62b3ccc8000000000000 };
1080 #elif BITS_PER_MP_LIMB == 256
1081 const mp_limb_t mpfr_l2b_29_1__tab[] = { 0xd2c983159c6c62b3ccc800000000000000000000000000000000000000000000 };
1082 #endif
1084 #if 0
1085 #elif BITS_PER_MP_LIMB == 16
1086 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x4000, 0x9d05 };
1087 #elif BITS_PER_MP_LIMB == 32
1088 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d054000 };
1089 #elif BITS_PER_MP_LIMB == 64
1090 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d05400000000000 };
1091 #elif BITS_PER_MP_LIMB == 96
1092 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d0540000000000000000000 };
1093 #elif BITS_PER_MP_LIMB == 128
1094 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d054000000000000000000000000000 };
1095 #elif BITS_PER_MP_LIMB == 256
1096 const mp_limb_t mpfr_l2b_30_0__tab[] = { 0x9d05400000000000000000000000000000000000000000000000000000000000 };
1097 #endif
1099 #if 0
1100 #elif BITS_PER_MP_LIMB == 16
1101 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0x3588, 0x1732, 0x5cad, 0xa619, 0xd0af };
1102 #elif BITS_PER_MP_LIMB == 32
1103 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0x35880000, 0x5cad1732, 0xd0afa619 };
1104 #elif BITS_PER_MP_LIMB == 64
1105 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0x3588000000000000, 0xd0afa6195cad1732 };
1106 #elif BITS_PER_MP_LIMB == 96
1107 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0xd0afa6195cad173235880000 };
1108 #elif BITS_PER_MP_LIMB == 128
1109 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0xd0afa6195cad17323588000000000000 };
1110 #elif BITS_PER_MP_LIMB == 256
1111 const mp_limb_t mpfr_l2b_30_1__tab[] = { 0xd0afa6195cad1732358800000000000000000000000000000000000000000000 };
1112 #endif
1114 #if 0
1115 #elif BITS_PER_MP_LIMB == 16
1116 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0xc800, 0x9e88 };
1117 #elif BITS_PER_MP_LIMB == 32
1118 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c800 };
1119 #elif BITS_PER_MP_LIMB == 64
1120 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c80000000000 };
1121 #elif BITS_PER_MP_LIMB == 96
1122 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c8000000000000000000 };
1123 #elif BITS_PER_MP_LIMB == 128
1124 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c800000000000000000000000000 };
1125 #elif BITS_PER_MP_LIMB == 256
1126 const mp_limb_t mpfr_l2b_31_0__tab[] = { 0x9e88c80000000000000000000000000000000000000000000000000000000000 };
1127 #endif
1129 #if 0
1130 #elif BITS_PER_MP_LIMB == 16
1131 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xd578, 0xf7ca, 0x63ee, 0x86e6, 0xceb1 };
1132 #elif BITS_PER_MP_LIMB == 32
1133 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xd5780000, 0x63eef7ca, 0xceb186e6 };
1134 #elif BITS_PER_MP_LIMB == 64
1135 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xd578000000000000, 0xceb186e663eef7ca };
1136 #elif BITS_PER_MP_LIMB == 96
1137 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xceb186e663eef7cad5780000 };
1138 #elif BITS_PER_MP_LIMB == 128
1139 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xceb186e663eef7cad578000000000000 };
1140 #elif BITS_PER_MP_LIMB == 256
1141 const mp_limb_t mpfr_l2b_31_1__tab[] = { 0xceb186e663eef7cad57800000000000000000000000000000000000000000000 };
1142 #endif
1144 #if 0
1145 #elif BITS_PER_MP_LIMB == 16
1146 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0x0000, 0xa000 };
1147 #elif BITS_PER_MP_LIMB == 32
1148 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa0000000 };
1149 #elif BITS_PER_MP_LIMB == 64
1150 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa000000000000000 };
1151 #elif BITS_PER_MP_LIMB == 96
1152 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa00000000000000000000000 };
1153 #elif BITS_PER_MP_LIMB == 128
1154 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa0000000000000000000000000000000 };
1155 #elif BITS_PER_MP_LIMB == 256
1156 const mp_limb_t mpfr_l2b_32_0__tab[] = { 0xa000000000000000000000000000000000000000000000000000000000000000 };
1157 #endif
1159 #if 0
1160 #elif BITS_PER_MP_LIMB == 16
1161 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccd0, 0xcccc, 0xcccc, 0xcccc, 0xcccc };
1162 #elif BITS_PER_MP_LIMB == 32
1163 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccd00000, 0xcccccccc, 0xcccccccc };
1164 #elif BITS_PER_MP_LIMB == 64
1165 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccd0000000000000, 0xcccccccccccccccc };
1166 #elif BITS_PER_MP_LIMB == 96
1167 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccccccccccccccccccd00000 };
1168 #elif BITS_PER_MP_LIMB == 128
1169 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccccccccccccccccccd0000000000000 };
1170 #elif BITS_PER_MP_LIMB == 256
1171 const mp_limb_t mpfr_l2b_32_1__tab[] = { 0xccccccccccccccccccd000000000000000000000000000000000000000000000 };
1172 #endif
1174 #if 0
1175 #elif BITS_PER_MP_LIMB == 16
1176 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xae00, 0xa16b };
1177 #elif BITS_PER_MP_LIMB == 32
1178 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae00 };
1179 #elif BITS_PER_MP_LIMB == 64
1180 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae0000000000 };
1181 #elif BITS_PER_MP_LIMB == 96
1182 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae000000000000000000 };
1183 #elif BITS_PER_MP_LIMB == 128
1184 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae00000000000000000000000000 };
1185 #elif BITS_PER_MP_LIMB == 256
1186 const mp_limb_t mpfr_l2b_33_0__tab[] = { 0xa16bae0000000000000000000000000000000000000000000000000000000000 };
1187 #endif
1189 #if 0
1190 #elif BITS_PER_MP_LIMB == 16
1191 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0x0888, 0xa187, 0x5304, 0x6404, 0xcaff };
1192 #elif BITS_PER_MP_LIMB == 32
1193 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0x08880000, 0x5304a187, 0xcaff6404 };
1194 #elif BITS_PER_MP_LIMB == 64
1195 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0x0888000000000000, 0xcaff64045304a187 };
1196 #elif BITS_PER_MP_LIMB == 96
1197 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0xcaff64045304a18708880000 };
1198 #elif BITS_PER_MP_LIMB == 128
1199 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0xcaff64045304a1870888000000000000 };
1200 #elif BITS_PER_MP_LIMB == 256
1201 const mp_limb_t mpfr_l2b_33_1__tab[] = { 0xcaff64045304a187088800000000000000000000000000000000000000000000 };
1202 #endif
1204 #if 0
1205 #elif BITS_PER_MP_LIMB == 16
1206 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0x8000, 0xa2cc };
1207 #elif BITS_PER_MP_LIMB == 32
1208 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc8000 };
1209 #elif BITS_PER_MP_LIMB == 64
1210 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc800000000000 };
1211 #elif BITS_PER_MP_LIMB == 96
1212 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc80000000000000000000 };
1213 #elif BITS_PER_MP_LIMB == 128
1214 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc8000000000000000000000000000 };
1215 #elif BITS_PER_MP_LIMB == 256
1216 const mp_limb_t mpfr_l2b_34_0__tab[] = { 0xa2cc800000000000000000000000000000000000000000000000000000000000 };
1217 #endif
1219 #if 0
1220 #elif BITS_PER_MP_LIMB == 16
1221 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xfb50, 0x17ca, 0x5a79, 0x73d8, 0xc947 };
1222 #elif BITS_PER_MP_LIMB == 32
1223 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xfb500000, 0x5a7917ca, 0xc94773d8 };
1224 #elif BITS_PER_MP_LIMB == 64
1225 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xfb50000000000000, 0xc94773d85a7917ca };
1226 #elif BITS_PER_MP_LIMB == 96
1227 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xc94773d85a7917cafb500000 };
1228 #elif BITS_PER_MP_LIMB == 128
1229 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xc94773d85a7917cafb50000000000000 };
1230 #elif BITS_PER_MP_LIMB == 256
1231 const mp_limb_t mpfr_l2b_34_1__tab[] = { 0xc94773d85a7917cafb5000000000000000000000000000000000000000000000 };
1232 #endif
1234 #if 0
1235 #elif BITS_PER_MP_LIMB == 16
1236 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0x1800, 0xa423 };
1237 #elif BITS_PER_MP_LIMB == 32
1238 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa4231800 };
1239 #elif BITS_PER_MP_LIMB == 64
1240 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa423180000000000 };
1241 #elif BITS_PER_MP_LIMB == 96
1242 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa42318000000000000000000 };
1243 #elif BITS_PER_MP_LIMB == 128
1244 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa4231800000000000000000000000000 };
1245 #elif BITS_PER_MP_LIMB == 256
1246 const mp_limb_t mpfr_l2b_35_0__tab[] = { 0xa423180000000000000000000000000000000000000000000000000000000000 };
1247 #endif
1249 #if 0
1250 #elif BITS_PER_MP_LIMB == 16
1251 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0x6960, 0x18c2, 0x6037, 0x567c, 0xc7a3 };
1252 #elif BITS_PER_MP_LIMB == 32
1253 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0x69600000, 0x603718c2, 0xc7a3567c };
1254 #elif BITS_PER_MP_LIMB == 64
1255 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0x6960000000000000, 0xc7a3567c603718c2 };
1256 #elif BITS_PER_MP_LIMB == 96
1257 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0xc7a3567c603718c269600000 };
1258 #elif BITS_PER_MP_LIMB == 128
1259 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0xc7a3567c603718c26960000000000000 };
1260 #elif BITS_PER_MP_LIMB == 256
1261 const mp_limb_t mpfr_l2b_35_1__tab[] = { 0xc7a3567c603718c2696000000000000000000000000000000000000000000000 };
1262 #endif
1264 #if 0
1265 #elif BITS_PER_MP_LIMB == 16
1266 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0x0800, 0xa570 };
1267 #elif BITS_PER_MP_LIMB == 32
1268 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa5700800 };
1269 #elif BITS_PER_MP_LIMB == 64
1270 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa570080000000000 };
1271 #elif BITS_PER_MP_LIMB == 96
1272 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa57008000000000000000000 };
1273 #elif BITS_PER_MP_LIMB == 128
1274 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa5700800000000000000000000000000 };
1275 #elif BITS_PER_MP_LIMB == 256
1276 const mp_limb_t mpfr_l2b_36_0__tab[] = { 0xa570080000000000000000000000000000000000000000000000000000000000 };
1277 #endif
1279 #if 0
1280 #elif BITS_PER_MP_LIMB == 16
1281 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xff10, 0xf9e9, 0xe054, 0x9236, 0xc611 };
1282 #elif BITS_PER_MP_LIMB == 32
1283 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xff100000, 0xe054f9e9, 0xc6119236 };
1284 #elif BITS_PER_MP_LIMB == 64
1285 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xff10000000000000, 0xc6119236e054f9e9 };
1286 #elif BITS_PER_MP_LIMB == 96
1287 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xc6119236e054f9e9ff100000 };
1288 #elif BITS_PER_MP_LIMB == 128
1289 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xc6119236e054f9e9ff10000000000000 };
1290 #elif BITS_PER_MP_LIMB == 256
1291 const mp_limb_t mpfr_l2b_36_1__tab[] = { 0xc6119236e054f9e9ff1000000000000000000000000000000000000000000000 };
1292 #endif
1294 const __mpfr_struct __gmpfr_l2b[BASE_MAX-1][2] = {
1295 { { 23, 1, 1, (mp_limb_t *) mpfr_l2b_2_0__tab },
1296 { 77, 1, 1, (mp_limb_t *) mpfr_l2b_2_1__tab } },
1297 { { 23, 1, 1, (mp_limb_t *) mpfr_l2b_3_0__tab },
1298 { 77, 1, 0, (mp_limb_t *) mpfr_l2b_3_1__tab } },
1299 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_4_0__tab },
1300 { 77, 1, 0, (mp_limb_t *) mpfr_l2b_4_1__tab } },
1301 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_5_0__tab },
1302 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_5_1__tab } },
1303 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_6_0__tab },
1304 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_6_1__tab } },
1305 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_7_0__tab },
1306 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_7_1__tab } },
1307 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_8_0__tab },
1308 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_8_1__tab } },
1309 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_9_0__tab },
1310 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_9_1__tab } },
1311 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_10_0__tab },
1312 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_10_1__tab } },
1313 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_11_0__tab },
1314 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_11_1__tab } },
1315 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_12_0__tab },
1316 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_12_1__tab } },
1317 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_13_0__tab },
1318 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_13_1__tab } },
1319 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_14_0__tab },
1320 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_14_1__tab } },
1321 { { 23, 1, 2, (mp_limb_t *) mpfr_l2b_15_0__tab },
1322 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_15_1__tab } },
1323 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_16_0__tab },
1324 { 77, 1, -1, (mp_limb_t *) mpfr_l2b_16_1__tab } },
1325 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_17_0__tab },
1326 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_17_1__tab } },
1327 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_18_0__tab },
1328 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_18_1__tab } },
1329 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_19_0__tab },
1330 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_19_1__tab } },
1331 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_20_0__tab },
1332 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_20_1__tab } },
1333 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_21_0__tab },
1334 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_21_1__tab } },
1335 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_22_0__tab },
1336 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_22_1__tab } },
1337 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_23_0__tab },
1338 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_23_1__tab } },
1339 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_24_0__tab },
1340 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_24_1__tab } },
1341 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_25_0__tab },
1342 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_25_1__tab } },
1343 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_26_0__tab },
1344 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_26_1__tab } },
1345 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_27_0__tab },
1346 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_27_1__tab } },
1347 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_28_0__tab },
1348 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_28_1__tab } },
1349 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_29_0__tab },
1350 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_29_1__tab } },
1351 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_30_0__tab },
1352 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_30_1__tab } },
1353 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_31_0__tab },
1354 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_31_1__tab } },
1355 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_32_0__tab },
1356 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_32_1__tab } },
1357 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_33_0__tab },
1358 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_33_1__tab } },
1359 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_34_0__tab },
1360 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_34_1__tab } },
1361 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_35_0__tab },
1362 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_35_1__tab } },
1363 { { 23, 1, 3, (mp_limb_t *) mpfr_l2b_36_0__tab },
1364 { 77, 1, -2, (mp_limb_t *) mpfr_l2b_36_1__tab } } };
1366 /***************************************************************************/
1368 /* returns ceil(e * log2(b)^((-1)^i)), or ... + 1 */
1369 static mp_exp_t
1370 ceil_mul (mp_exp_t e, int beta, int i)
1372 mpfr_srcptr p;
1373 mpfr_t t;
1374 mp_exp_t r;
1376 p = &__gmpfr_l2b[beta-2][i];
1377 mpfr_init2 (t, sizeof (mp_exp_t) * CHAR_BIT);
1378 mpfr_set_exp_t (t, e, GMP_RNDU);
1379 mpfr_mul (t, t, p, GMP_RNDU);
1380 r = mpfr_get_exp_t (t, GMP_RNDU);
1381 mpfr_clear (t);
1382 return r;
1385 /* prints the mantissa of x in the string s, and writes the corresponding
1386 exponent in e.
1387 x is rounded with direction rnd, m is the number of digits of the mantissa,
1388 b is the given base (2 <= b <= 36).
1390 Return value:
1391 if s=NULL, allocates a string to store the mantissa, with
1392 m characters, plus a final '\0', plus a possible minus sign
1393 (thus m+1 or m+2 characters).
1395 Important: when you call this function with s=NULL, don't forget to free
1396 the memory space allocated, with free(s, strlen(s)).
1398 char*
1399 mpfr_get_str (char *s, mp_exp_t *e, int b, size_t m, mpfr_srcptr x, mp_rnd_t rnd)
1401 int exact; /* exact result */
1402 mp_exp_t exp, g;
1403 mp_exp_t prec; /* precision of the computation */
1404 long err;
1405 mp_limb_t *a;
1406 mp_exp_t exp_a;
1407 mp_limb_t *result;
1408 mp_limb_t *xp;
1409 mp_limb_t *reste;
1410 size_t nx, nx1;
1411 size_t n, i;
1412 char *s0;
1413 int neg;
1414 int ret; /* return value of mpfr_get_str_aux */
1415 MPFR_ZIV_DECL (loop);
1416 MPFR_SAVE_EXPO_DECL (expo);
1417 MPFR_TMP_DECL(marker);
1419 /* if exact = 1 then err is undefined */
1420 /* otherwise err is such that |x*b^(m-g)-a*2^exp_a| < 2^(err+exp_a) */
1422 /* is the base valid? */
1423 if (b < 2 || b > 36)
1424 return NULL;
1426 if (MPFR_UNLIKELY (MPFR_IS_NAN (x)))
1428 if (s == NULL)
1429 s = (char *) (*__gmp_allocate_func) (6);
1430 strcpy (s, "@NaN@");
1431 return s;
1434 neg = MPFR_SIGN(x) < 0; /* 0 if positive, 1 if negative */
1436 if (MPFR_UNLIKELY (MPFR_IS_INF (x)))
1438 if (s == NULL)
1439 s = (char *) (*__gmp_allocate_func) (neg + 6);
1440 strcpy (s, (neg) ? "-@Inf@" : "@Inf@");
1441 return s;
1444 MPFR_SAVE_EXPO_MARK (expo); /* needed for ceil_mul (at least) */
1446 if (m == 0)
1449 /* take at least 1 + ceil(n*log(2)/log(b)) digits, where n is the
1450 number of bits of the mantissa, to ensure back conversion from
1451 the output gives the same floating-point.
1453 Warning: if b = 2^k, this may be too large. The worst case is when
1454 the first base-b digit contains only one bit, so we get
1455 1 + ceil((n-1)/k) = 2 + floor((n-2)/k) instead.
1457 m = 1 + ceil_mul (IS_POW2(b) ? MPFR_PREC(x) - 1: MPFR_PREC(x), b, 1);
1458 if (m < 2)
1459 m = 2;
1462 /* the code below for non-power-of-two bases works for m=1 */
1463 MPFR_ASSERTN (m >= 2 || (IS_POW2(b) == 0 && m >= 1));
1465 /* x is a floating-point number */
1467 if (MPFR_IS_ZERO(x))
1469 if (s == NULL)
1470 s = (char*) (*__gmp_allocate_func) (neg + m + 1);
1471 s0 = s;
1472 if (neg)
1473 *s++ = '-';
1474 memset (s, '0', m);
1475 s[m] = '\0';
1476 *e = 0; /* a bit like frexp() in ISO C99 */
1477 MPFR_SAVE_EXPO_FREE (expo);
1478 return s0; /* strlen(s0) = neg + m */
1481 if (s == NULL)
1482 s = (char*) (*__gmp_allocate_func) (neg + m + 1);
1483 s0 = s;
1484 if (neg)
1485 *s++ = '-';
1487 xp = MPFR_MANT(x);
1489 if (IS_POW2(b))
1491 int pow2;
1492 mp_exp_t f, r;
1493 mp_limb_t *x1;
1494 mp_size_t nb;
1495 int inexp;
1497 count_leading_zeros (pow2, (mp_limb_t) b);
1498 pow2 = BITS_PER_MP_LIMB - pow2 - 1; /* base = 2^pow2 */
1500 /* set MPFR_EXP(x) = f*pow2 + r, 1 <= r <= pow2 */
1501 f = (MPFR_GET_EXP (x) - 1) / pow2;
1502 r = MPFR_GET_EXP (x) - f * pow2;
1503 if (r <= 0)
1505 f --;
1506 r += pow2;
1509 /* the first digit will contain only r bits */
1510 prec = (m - 1) * pow2 + r; /* total number of bits */
1511 n = (prec - 1) / BITS_PER_MP_LIMB + 1;
1513 MPFR_TMP_MARK (marker);
1514 x1 = (mp_limb_t*) MPFR_TMP_ALLOC((n + 1) * sizeof (mp_limb_t));
1515 nb = n * BITS_PER_MP_LIMB - prec;
1516 /* round xp to the precision prec, and put it into x1
1517 put the carry into x1[n] */
1518 if ((x1[n] = mpfr_round_raw (x1, xp, MPFR_PREC(x),
1519 MPFR_IS_STRICTNEG(x),
1520 prec, rnd, &inexp)))
1522 /* overflow when rounding x: x1 = 2^prec */
1523 if (r == pow2) /* prec = m * pow2,
1524 2^prec will need (m+1) digits in base 2^pow2 */
1526 /* divide x1 by 2^pow2, and increase the exponent */
1527 mpn_rshift (x1, x1, n + 1, pow2);
1528 f ++;
1530 else /* 2^prec needs still m digits, but x1 may need n+1 limbs */
1531 n ++;
1534 /* it remains to shift x1 by nb limbs to the right, since mpn_get_str
1535 expects a right-normalized number */
1536 if (nb != 0)
1538 mpn_rshift (x1, x1, n, nb);
1539 /* the most significant word may be zero */
1540 if (x1[n - 1] == 0)
1541 n --;
1544 mpn_get_str ((unsigned char*) s, b, x1, n);
1545 for (i=0; i<m; i++)
1546 s[i] = num_to_text[(int) s[i]];
1547 s[m] = 0;
1549 /* the exponent of s is f + 1 */
1550 *e = f + 1;
1552 MPFR_TMP_FREE(marker);
1553 MPFR_SAVE_EXPO_FREE (expo);
1554 return (s0);
1557 /* if x < 0, reduce to x > 0 */
1558 if (neg)
1559 rnd = MPFR_INVERT_RND(rnd);
1561 g = ceil_mul (MPFR_GET_EXP (x) - 1, b, 1);
1562 exact = 1;
1563 prec = ceil_mul (m, b, 0) + 1;
1564 exp = ((mp_exp_t) m < g) ? g - (mp_exp_t) m : (mp_exp_t) m - g;
1565 prec += MPFR_INT_CEIL_LOG2 (prec); /* number of guard bits */
1566 if (exp != 0) /* add maximal exponentiation error */
1567 prec += 3 * (mp_exp_t) MPFR_INT_CEIL_LOG2 (exp);
1569 MPFR_ZIV_INIT (loop, prec);
1570 for (;;)
1572 MPFR_TMP_MARK(marker);
1574 exact = 1;
1576 /* number of limbs */
1577 n = 1 + (prec - 1) / BITS_PER_MP_LIMB;
1579 /* a will contain the approximation of the mantissa */
1580 a = (mp_limb_t*) MPFR_TMP_ALLOC (n * sizeof (mp_limb_t));
1582 nx = 1 + (MPFR_PREC(x) - 1) / BITS_PER_MP_LIMB;
1584 if ((mp_exp_t) m == g) /* final exponent is 0, no multiplication or
1585 division to perform */
1587 if (nx > n)
1588 exact = mpn_scan1 (xp, 0) >= (nx - n) * BITS_PER_MP_LIMB;
1589 err = !exact;
1590 MPN_COPY2 (a, n, xp, nx);
1591 exp_a = MPFR_GET_EXP (x) - n * BITS_PER_MP_LIMB;
1593 else if ((mp_exp_t) m > g) /* we have to multiply x by b^exp */
1595 mp_limb_t *x1;
1597 /* a2*2^exp_a = b^e */
1598 err = mpfr_mpn_exp (a, &exp_a, b, exp, n);
1599 /* here, the error on a is at most 2^err ulps */
1600 exact = (err == -1);
1602 /* x = x1*2^(n*BITS_PER_MP_LIMB) */
1603 x1 = (nx >= n) ? xp + nx - n : xp;
1604 nx1 = (nx >= n) ? n : nx; /* nx1 = min(n, nx) */
1606 /* test si exact */
1607 if (nx > n)
1608 exact = (exact &&
1609 ((mpn_scan1 (xp, 0) >= (nx - n) * BITS_PER_MP_LIMB)));
1611 /* we loose one more bit in the multiplication,
1612 except when err=0 where we loose two bits */
1613 err = (err <= 0) ? 2 : err + 1;
1615 /* result = a * x */
1616 result = (mp_limb_t*) MPFR_TMP_ALLOC ((n + nx1) * sizeof (mp_limb_t));
1617 mpn_mul (result, a, n, x1, nx1);
1618 exp_a += MPFR_GET_EXP (x);
1619 if (mpn_scan1 (result, 0) < (nx1 * BITS_PER_MP_LIMB))
1620 exact = 0;
1622 /* normalize a and truncate */
1623 if ((result[n + nx1 - 1] & MPFR_LIMB_HIGHBIT) == 0)
1625 mpn_lshift (a, result + nx1, n , 1);
1626 a[0] |= result[nx1 - 1] >> (BITS_PER_MP_LIMB - 1);
1627 exp_a --;
1629 else
1630 MPN_COPY (a, result + nx1, n);
1632 else
1634 mp_limb_t *x1;
1636 /* a2*2^exp_a = b^e */
1637 err = mpfr_mpn_exp (a, &exp_a, b, exp, n);
1638 exact = (err == -1);
1640 /* allocate memory for x1, result and reste */
1641 x1 = (mp_limb_t*) MPFR_TMP_ALLOC (2 * n * sizeof (mp_limb_t));
1642 result = (mp_limb_t*) MPFR_TMP_ALLOC ((n + 1) * sizeof (mp_limb_t));
1643 reste = (mp_limb_t*) MPFR_TMP_ALLOC (n * sizeof (mp_limb_t));
1645 /* initialize x1 = x */
1646 MPN_COPY2 (x1, 2 * n, xp, nx);
1647 if ((exact) && (nx > 2 * n) &&
1648 (mpn_scan1 (xp, 0) < (nx - 2 * n) * BITS_PER_MP_LIMB))
1649 exact = 0;
1651 /* result = x / a */
1652 mpn_tdiv_qr (result, reste, 0, x1, 2 * n, a, n);
1653 exp_a = MPFR_GET_EXP (x) - exp_a - 2 * n * BITS_PER_MP_LIMB;
1655 /* test if division was exact */
1656 if (exact)
1657 exact = mpn_popcount (reste, n) == 0;
1659 /* normalize the result and copy into a */
1660 if (result[n] == 1)
1662 mpn_rshift (a, result, n, 1);
1663 a[n - 1] |= MPFR_LIMB_HIGHBIT;;
1664 exp_a ++;
1666 else
1667 MPN_COPY (a, result, n);
1669 err = (err == -1) ? 2 : err + 2;
1672 /* check if rounding is possible */
1673 if (exact)
1674 err = -1;
1675 ret = mpfr_get_str_aux (s, e, a, n, exp_a, err, b, m, rnd);
1676 if (ret == MPFR_ROUND_FAILED)
1678 /* too large error: increment the working precision */
1679 MPFR_ZIV_NEXT (loop, prec);
1681 else if (ret == -MPFR_ROUND_FAILED)
1683 /* too many digits in mantissa: exp = |m-g| */
1684 if ((mp_exp_t) m > g) /* exp = m - g, multiply by b^exp */
1686 g++;
1687 exp --;
1689 else /* exp = g - m, divide by b^exp */
1691 g++;
1692 exp ++;
1695 else
1696 break;
1698 MPFR_TMP_FREE(marker);
1700 MPFR_ZIV_FREE (loop);
1702 *e += g;
1704 MPFR_TMP_FREE(marker);
1705 MPFR_SAVE_EXPO_FREE (expo);
1706 return s0;
1709 void mpfr_free_str (char *str)
1711 (*__gmp_free_func) (str, strlen (str) + 1);