factor/native/bignum.h

55 lines
1.3 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-06 02:51:32 -04:00
/* FIXME */
#ifndef FACTOR_64
CELL alignment;
#endif
2004-07-28 19:02:24 -04:00
BIGNUM_2 n;
} BIGNUM;
/* untagged */
INLINE BIGNUM* allot_bignum()
{
2004-08-05 16:49:55 -04:00
return allot_object(BIGNUM_TYPE,sizeof(BIGNUM));
}
/* 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(CELL x, CELL y);
CELL add_bignum(CELL x, CELL y);
CELL subtract_bignum(CELL x, CELL y);
CELL multiply_bignum(CELL x, CELL y);
BIGNUM_2 gcd_bignum(BIGNUM_2 x, BIGNUM_2 y);
CELL divide_bignum(CELL x, CELL y);
CELL divint_bignum(CELL x, CELL y);
2004-08-05 16:49:55 -04:00
CELL divfloat_bignum(CELL x, CELL y);
2004-08-05 15:18:31 -04:00
CELL divmod_bignum(CELL x, CELL y);
CELL mod_bignum(CELL x, CELL y);
CELL and_bignum(CELL x, CELL y);
CELL or_bignum(CELL x, CELL y);
CELL xor_bignum(CELL x, CELL y);
CELL shiftleft_bignum(CELL x, CELL y);
CELL shiftright_bignum(CELL x, CELL y);
CELL less_bignum(CELL x, CELL y);
CELL lesseq_bignum(CELL x, CELL y);
CELL greater_bignum(CELL x, CELL y);
CELL greatereq_bignum(CELL x, CELL y);
2004-08-17 23:42:10 -04:00
CELL not_bignum(CELL x);