354 |
} |
} |
355 |
|
|
356 |
|
|
357 |
|
/* put in to get (declare integer working with existing setup. |
358 |
|
should be optimized at some point, as we're just converting |
359 |
|
and reconverting integer data, it appears -- CM */ |
360 |
|
|
361 |
|
int |
362 |
|
obj_to_mpz(object x,MP_INT * y) { |
363 |
|
|
364 |
|
int ret=0; |
365 |
|
|
366 |
|
switch(type_of(x)) { |
367 |
|
case t_fixnum: |
368 |
|
mpz_set_si(y,fix(x)); |
369 |
|
break; |
370 |
|
case t_bignum: |
371 |
|
mpz_set(y,MP(x)); |
372 |
|
break; |
373 |
|
default: |
374 |
|
FEerror("fixnum or bignum expected",0); |
375 |
|
ret=1; |
376 |
|
break; |
377 |
|
} |
378 |
|
|
379 |
|
return ret; |
380 |
|
|
381 |
|
} |
382 |
|
|
383 |
|
int |
384 |
|
mpz_to_mpz(MP_INT * x,MP_INT * y) { |
385 |
|
|
386 |
|
int ret=0; |
387 |
|
|
388 |
|
mpz_set(y,x); |
389 |
|
return ret; |
390 |
|
|
391 |
|
} |
392 |
|
|
393 |
|
void |
394 |
|
isetq_fix(MP_INT * var,int s) |
395 |
|
{ |
396 |
|
mpz_set_si(var,s); |
397 |
|
} |
398 |
|
|
399 |
|
MP_INT * |
400 |
|
otoi(object x) { |
401 |
|
if (type_of(x)==t_fixnum) { |
402 |
|
object y = new_bignum(); |
403 |
|
mpz_set_si(MP(y),fix(x)); |
404 |
|
return MP(y); |
405 |
|
} |
406 |
|
if (type_of(x)==t_bignum) |
407 |
|
return (MP(x)); |
408 |
|
FEwrong_type_argument(sLinteger,x); |
409 |
|
return NULL; |
410 |
|
} |
411 |
|
/* end added section for declare integer -- CM */ |
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
/* return object like *xpt coercing to a fixnum if necessary, |
/* return object like *xpt coercing to a fixnum if necessary, |