111 |
static void numb_initialise (void); |
static void numb_initialise (void); |
112 |
static void numb_obstack (struct obstack *obs, const number value, |
static void numb_obstack (struct obstack *obs, const number value, |
113 |
const int radix, int min); |
const int radix, int min); |
114 |
static void mpq2mpz (mpz_t z, const number q, const char *noisily); |
static void mpq2mpz (m4 *context, mpz_t z, const number q, const char *noisily); |
115 |
static void mpz2mpq (number q, const mpz_t z); |
static void mpz2mpq (number q, const mpz_t z); |
116 |
static void numb_divide (number *x, const number *y); |
static void numb_divide (number *x, const number *y); |
117 |
static void numb_modulo (number *x, const number *y); |
static void numb_modulo (m4 *context, number *x, const number *y); |
118 |
static void numb_and (number *x, const number *y); |
static void numb_and (m4 *context, number *x, const number *y); |
119 |
static void numb_ior (number *x, const number *y); |
static void numb_ior (m4 *context, number *x, const number *y); |
120 |
static void numb_eor (number *x, const number *y); |
static void numb_eor (m4 *context, number *x, const number *y); |
121 |
static void numb_not (number *x); |
static void numb_not (m4 *context, number *x); |
122 |
static void numb_lshift (number *x, const number *y); |
static void numb_lshift (m4 *context, number *x, const number *y); |
123 |
static void numb_rshift (number *x, const number *y); |
static void numb_rshift (m4 *context, number *x, const number *y); |
124 |
|
|
125 |
|
|
126 |
static number numb_ZERO; |
static number numb_ZERO; |
181 |
#define QUIET (char *)0 |
#define QUIET (char *)0 |
182 |
|
|
183 |
static void |
static void |
184 |
mpq2mpz (mpz_t z, const number q, const char *noisily) |
mpq2mpz (m4 *context, mpz_t z, const number q, const char *noisily) |
185 |
{ |
{ |
186 |
if (noisily && mpz_cmp_si (mpq_denref (q), (long) 1) != 0) |
if (noisily && mpz_cmp_si (mpq_denref (q), (long) 1) != 0) |
187 |
{ |
{ |
188 |
M4ERROR ((warning_status, 0, |
M4ERROR ((m4_get_warning_status_opt (context), 0, |
189 |
_("Loss of precision in eval: %s"), noisily)); |
_("Loss of precision in eval: %s"), noisily)); |
190 |
} |
} |
191 |
|
|
217 |
} |
} |
218 |
|
|
219 |
static void |
static void |
220 |
numb_modulo (number * x, const number * y) |
numb_modulo (m4 *context, number * x, const number * y) |
221 |
{ |
{ |
222 |
mpz_t xx, yy, res; |
mpz_t xx, yy, res; |
223 |
|
|
225 |
/* y should be integral */ |
/* y should be integral */ |
226 |
|
|
227 |
mpz_init (xx); |
mpz_init (xx); |
228 |
mpq2mpz (xx, *x, NOISY); |
mpq2mpz (context, xx, *x, NOISY); |
229 |
|
|
230 |
mpz_init (yy); |
mpz_init (yy); |
231 |
mpq2mpz (yy, *y, NOISY); |
mpq2mpz (context, yy, *y, NOISY); |
232 |
|
|
233 |
mpz_init (res); |
mpz_init (res); |
234 |
mpz_mod (res, xx, yy); |
mpz_mod (res, xx, yy); |
241 |
} |
} |
242 |
|
|
243 |
static void |
static void |
244 |
numb_and (number * x, const number * y) |
numb_and (m4 *context, number * x, const number * y) |
245 |
{ |
{ |
246 |
mpz_t xx, yy, res; |
mpz_t xx, yy, res; |
247 |
|
|
249 |
/* y should be integral */ |
/* y should be integral */ |
250 |
|
|
251 |
mpz_init (xx); |
mpz_init (xx); |
252 |
mpq2mpz (xx, *x, NOISY); |
mpq2mpz (context, xx, *x, NOISY); |
253 |
|
|
254 |
mpz_init (yy); |
mpz_init (yy); |
255 |
mpq2mpz (yy, *y, NOISY); |
mpq2mpz (context, yy, *y, NOISY); |
256 |
|
|
257 |
mpz_init (res); |
mpz_init (res); |
258 |
mpz_and (res, xx, yy); |
mpz_and (res, xx, yy); |
265 |
} |
} |
266 |
|
|
267 |
static void |
static void |
268 |
numb_ior (number * x, const number * y) |
numb_ior (m4 *context, number * x, const number * y) |
269 |
{ |
{ |
270 |
mpz_t xx, yy, res; |
mpz_t xx, yy, res; |
271 |
|
|
273 |
/* y should be integral */ |
/* y should be integral */ |
274 |
|
|
275 |
mpz_init (xx); |
mpz_init (xx); |
276 |
mpq2mpz (xx, *x, NOISY); |
mpq2mpz (context, xx, *x, NOISY); |
277 |
|
|
278 |
mpz_init (yy); |
mpz_init (yy); |
279 |
mpq2mpz (yy, *y, NOISY); |
mpq2mpz (context, yy, *y, NOISY); |
280 |
|
|
281 |
mpz_init (res); |
mpz_init (res); |
282 |
mpz_ior (res, xx, yy); |
mpz_ior (res, xx, yy); |
289 |
} |
} |
290 |
|
|
291 |
static void |
static void |
292 |
numb_eor (number * x, const number * y) |
numb_eor (m4 *context, number * x, const number * y) |
293 |
{ |
{ |
294 |
mpz_t xx, yy, res; |
mpz_t xx, yy, res; |
295 |
|
|
297 |
/* y should be integral */ |
/* y should be integral */ |
298 |
|
|
299 |
mpz_init (xx); |
mpz_init (xx); |
300 |
mpq2mpz (xx, *x, NOISY); |
mpq2mpz (context, xx, *x, NOISY); |
301 |
|
|
302 |
mpz_init (yy); |
mpz_init (yy); |
303 |
mpq2mpz (yy, *y, NOISY); |
mpq2mpz (context, yy, *y, NOISY); |
304 |
|
|
305 |
mpz_init (res); |
mpz_init (res); |
306 |
|
|
336 |
} |
} |
337 |
|
|
338 |
static void |
static void |
339 |
numb_not (number * x) |
numb_not (m4 *context, number * x) |
340 |
{ |
{ |
341 |
mpz_t xx, res; |
mpz_t xx, res; |
342 |
|
|
343 |
/* x should be integral */ |
/* x should be integral */ |
344 |
|
|
345 |
mpz_init (xx); |
mpz_init (xx); |
346 |
mpq2mpz (xx, *x, NOISY); |
mpq2mpz (context, xx, *x, NOISY); |
347 |
|
|
348 |
mpz_init (res); |
mpz_init (res); |
349 |
mpz_com (res, xx); |
mpz_com (res, xx); |
355 |
} |
} |
356 |
|
|
357 |
static void |
static void |
358 |
numb_lshift (number * x, const number * y) |
numb_lshift (m4 *context, number * x, const number * y) |
359 |
{ |
{ |
360 |
mpz_t xx, yy, res; |
mpz_t xx, yy, res; |
361 |
|
|
363 |
/* y should be integral */ |
/* y should be integral */ |
364 |
|
|
365 |
mpz_init (xx); |
mpz_init (xx); |
366 |
mpq2mpz (xx, *x, NOISY); |
mpq2mpz (context, xx, *x, NOISY); |
367 |
|
|
368 |
mpz_init (yy); |
mpz_init (yy); |
369 |
mpq2mpz (yy, *y, NOISY); |
mpq2mpz (context, yy, *y, NOISY); |
370 |
|
|
371 |
mpz_init (res); |
mpz_init (res); |
372 |
{ |
{ |
390 |
} |
} |
391 |
|
|
392 |
static void |
static void |
393 |
numb_rshift (number * x, const number * y) |
numb_rshift (m4 *context, number * x, const number * y) |
394 |
{ |
{ |
395 |
mpz_t xx, yy, res; |
mpz_t xx, yy, res; |
396 |
|
|
398 |
/* y should be integral */ |
/* y should be integral */ |
399 |
|
|
400 |
mpz_init (xx); |
mpz_init (xx); |
401 |
mpq2mpz (xx, *x, NOISY); |
mpq2mpz (context, xx, *x, NOISY); |
402 |
|
|
403 |
mpz_init (yy); |
mpz_init (yy); |
404 |
mpq2mpz (yy, *y, NOISY); |
mpq2mpz (context, yy, *y, NOISY); |
405 |
|
|
406 |
mpz_init (res); |
mpz_init (res); |
407 |
{ |
{ |