VAL bigMod(VM* vm, VAL x, VAL y) { mpz_t* bigint; VAL cl = allocate(vm, sizeof(Closure) + sizeof(mpz_t), 0); bigint = (mpz_t*)(((char*)cl) + sizeof(Closure)); mpz_mod(*bigint, GETMPZ(GETBIG(vm,x)), GETMPZ(GETBIG(vm,y))); SETTY(cl, BIGINT); cl -> info.ptr = (void*)bigint; return cl; }
VAL bigDiv(VM* vm, VAL x, VAL y) { mpz_t* bigint; VAL cl = allocate(vm, sizeof(ClosureType) + sizeof(void*)); bigint = allocate(vm, sizeof(mpz_t)); mpz_div(*bigint, GETMPZ(x), GETMPZ(y)); cl -> ty = BIGINT; cl -> info.ptr = (void*)bigint; return cl; }
VAL bigMul(VM* vm, VAL x, VAL y) { mpz_t* bigint; VAL cl = allocate(vm, sizeof(ClosureType) + sizeof(void*) + sizeof(mpz_t), 0); bigint = (mpz_t*)(((char*)cl) + sizeof(ClosureType) + sizeof(void*)); mpz_mul(*bigint, GETMPZ(x), GETMPZ(y)); SETTY(cl, BIGINT); cl -> info.ptr = (void*)bigint; return cl; }
VAL bigDiv(VM* vm, VAL x, VAL y) { idris_requireAlloc(IDRIS_MAXGMP); mpz_t* bigint; VAL cl = allocate(sizeof(Closure) + sizeof(mpz_t), 0); bigint = (mpz_t*)(((char*)cl) + sizeof(Closure)); mpz_tdiv_q(*bigint, GETMPZ(GETBIG(vm,x)), GETMPZ(GETBIG(vm,y))); SETTY(cl, BIGINT); cl -> info.ptr = (void*)bigint; return cl; }
VAL bigAShiftRight(VM* vm, VAL x, VAL y) { idris_requireAlloc(IDRIS_MAXGMP); mpz_t* bigint; VAL cl = allocate(sizeof(Closure) + sizeof(mpz_t), 0); idris_doneAlloc(); bigint = (mpz_t*)(((char*)cl) + sizeof(Closure)); mpz_fdiv_q_2exp(*bigint, GETMPZ(GETBIG(vm,x)), GETINT(y)); SETTY(cl, CT_BIGINT); cl -> info.ptr = (void*)bigint; return cl; }