1 /* cre-conv-tab.c -- Create conversion table in a wordsize-dependent way.
3 Copyright (C) 1991 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
7 The GNU MP Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 The GNU MP Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with the GNU MP Library; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 extern double floor ();
28 static unsigned long int
33 unsigned long int y = 1;
54 for (i = 0; x != 0; i++)
63 unsigned long big_base, big_base_inverted;
66 int normalization_steps;
68 unsigned long int max_uli;
74 if ((max_uli << 1) == 0)
80 puts ("/* __mp_bases -- Structure for conversion between internal binary");
81 puts (" format and strings in base 2..36. The fields are explained in");
82 puts (" gmp-impl.h.");
84 puts (" ***** THIS FILE WAS CREATED BY A PROGRAM. DON'T EDIT IT! *****");
86 puts ("Copyright (C) 1991 Free Software Foundation, Inc.");
88 puts ("This file is part of the GNU MP Library.");
90 puts ("The GNU MP Library is free software; you can redistribute it and/or");
91 puts ("modify it under the terms of the GNU General Public License as");
92 puts ("published by the Free Software Foundation; either version 2, or");
93 puts ("(at your option) any later version.");
95 puts ("The GNU MP Library is distributed in the hope that it will be");
96 puts ("useful, but WITHOUT ANY WARRANTY; without even the implied warranty");
97 puts ("of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the");
98 puts ("GNU General Public License for more details.");
100 puts ("You should have received a copy of the GNU General Public License");
101 puts ("along with the GNU MP Library; see the file COPYING. If not, write");
102 puts ("to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,");
105 puts ("#include \"gmp.h\"");
106 puts ("#include \"gmp-impl.h\"");
109 puts ("const struct bases __mp_bases[37] =\n{");
110 puts (" /* 0 */ {0, 0, 0, 0.0},");
111 puts (" /* 1 */ {0, 0, 0, 0.0},");
112 for (i = 2; i <= 36; i++)
114 /* The weird expression here is because many /bin/cc compilers
115 generate incorrect code for conversions from large unsigned
116 integers to double. */
117 fdig = log(2.0)/log((double) i);
118 idig = floor(bits_uli * fdig);
119 if ((i & (i - 1)) == 0)
121 big_base = ulog2 (i) - 1;
122 big_base_inverted = 0;
126 big_base = upow (i, idig);
127 for (normalization_steps = 0;
128 (long int) (big_base << normalization_steps) >= 0;
129 normalization_steps++)
131 udiv_qrnnd (big_base_inverted, dummy,
132 -(big_base << normalization_steps), 0,
133 big_base << normalization_steps);
135 printf (" /* %2u */ {%lu, 0x%lX, 0x%lX, %.8f},\n",
136 i, idig, big_base, big_base_inverted, fdig);