big2.c
Go to the documentation of this file.
00001 pointer 
00002 big_quotient_remainder_auxiliary(x, y, i)
00003 pointer x, y;
00004 int i;
00005 { pointer q, qq;
00006   int xsize, ysize, *xv, *yv, j, k;
00007   xsize=bigsize(x); ysize=bigsize(y);
00008 
00009   if (i < 0)    return(NULL);
00010   if (i == 0) {
00011         i = div_big_big(y, x);
00012         if (i == 0) return(NULL);
00013         else {
00014                 qq = makebig(1);
00015                 bigvec(qq)[0] = i;
00016                 return(qq);
00017         }
00018     }
00019 
00020   qq=makebig(i);
00021 
00022   for (k=i-1; k>=0; i--) {
00023     j=div_big_big
00024 
00025   q = big_quotient_remainder_auxiliary(x->big_cdr, y, i-1);
00026   i = div_big_big(y, x);
00027   vpush(((object)q));
00028   qq = (struct bignum *)alloc_object(t_bignum);
00029   
00030   qq->big_car = i;
00031   qq->big_cdr = q;
00032   return(qq);}
00033 
00034 /*
00035         Big_quotient_remainder(x0, y0, qp, rp)
00036         sets the quotient and the remainder of the division of x0 by y0
00037         to *qp and *rp respectively.
00038         X0 should be a positive bignum.
00039         Y0 should be a non-negative bignum.
00040 */
00041 big_quotient_remainder(x0, y0, qp, rp)
00042 pointer x0, y0, *qp, *rp;
00043 {
00044         context *ctx=euscontexts[thr_self()];
00045         pointer x, y;
00046         int i, l, m;
00047 
00048         x = copy_big(x0);
00049         vpush(x);
00050         y = y0;
00051         i = get_standardizing_factor_and_normalize(y);
00052         mul_int_big(i, x);
00053         mul_int_big(i, y);
00054         l = bigxize(x);
00055         m = bigsize(y);
00056         *qp = big_quotient_remainder_auxiliary(x, y, l - m);
00057         if (*qp == NULL) {
00058                 *qp = makebig(1);
00059                 (*qp)->c.bgnm.bv->c.ivec.iv[0] = 0;
00060         }
00061         div_int_big(i, x);
00062         div_int_big(i, y);
00063         vpop();
00064         *rp = x;
00065 }


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Mar 9 2017 04:57:49