factor/native/bignum.h

55 lines
1.4 KiB
C
Raw Normal View History

2004-07-28 19:02:24 -04:00
typedef long long BIGNUM_2;
typedef struct {
CELL header;
2004-08-24 23:46:55 -04:00
CELL capacity;
CELL sign;
CELL fill; /* bad */
2004-07-28 19:02:24 -04:00
BIGNUM_2 n;
} BIGNUM;
/* untagged */
INLINE BIGNUM* allot_bignum()
{
2004-08-24 23:46:55 -04:00
/* Bignums are really retrofitted arrays */
return (BIGNUM*)allot_array(BIGNUM_TYPE,4);
}
/* untagged */
2004-07-28 19:02:24 -04:00
INLINE BIGNUM* bignum(BIGNUM_2 n)
{
BIGNUM* bignum = allot_bignum();
bignum->n = n;
return bignum;
}
INLINE BIGNUM* untag_bignum(CELL tagged)
{
type_check(BIGNUM_TYPE,tagged);
return (BIGNUM*)UNTAG(tagged);
}
void primitive_bignump(void);
2004-08-05 15:18:31 -04:00
BIGNUM* to_bignum(CELL tagged);
void primitive_to_bignum(void);
CELL number_eq_bignum(BIGNUM* x, BIGNUM* y);
CELL add_bignum(BIGNUM* x, BIGNUM* y);
CELL subtract_bignum(BIGNUM* x, BIGNUM* y);
CELL multiply_bignum(BIGNUM* x, BIGNUM* y);
2004-08-05 15:18:31 -04:00
BIGNUM_2 gcd_bignum(BIGNUM_2 x, BIGNUM_2 y);
CELL divide_bignum(BIGNUM* x, BIGNUM* y);
CELL divint_bignum(BIGNUM* x, BIGNUM* y);
CELL divfloat_bignum(BIGNUM* x, BIGNUM* y);
CELL divmod_bignum(BIGNUM* x, BIGNUM* y);
CELL mod_bignum(BIGNUM* x, BIGNUM* y);
CELL and_bignum(BIGNUM* x, BIGNUM* y);
CELL or_bignum(BIGNUM* x, BIGNUM* y);
CELL xor_bignum(BIGNUM* x, BIGNUM* y);
CELL shiftleft_bignum(BIGNUM* x, BIGNUM* y);
CELL shiftright_bignum(BIGNUM* x, BIGNUM* y);
CELL less_bignum(BIGNUM* x, BIGNUM* y);
CELL lesseq_bignum(BIGNUM* x, BIGNUM* y);
CELL greater_bignum(BIGNUM* x, BIGNUM* y);
CELL greatereq_bignum(BIGNUM* x, BIGNUM* y);
CELL not_bignum(BIGNUM* x);