dl_t ldivide(dl_t lop, dl_t rop) { int cnt; dl_t ans; dl_t tmp; dl_t div; if (lsign(lop)) lop = lsub(lzero, lop); if (lsign(rop)) rop = lsub(lzero, rop); ans = lzero; div = lzero; for (cnt = 0; cnt < 63; cnt++) { div = lshiftl(div, 1); lop = lshiftl(lop, 1); if (lsign(lop)) div.dl_lop |= 1; tmp = lsub(div, rop); ans = lshiftl(ans, 1); if (lsign(tmp) == 0) { ans.dl_lop |= 1; div = tmp; } } return (ans); }
int main(void) { short a[N + 2] = {1999, 4444, 7777, 2222, 9999}, b[N + 2] = { 111, 6666, 3333, 8888, 1111}, c[N + 2]; ladd(a, b, c); print(c); lsub(a, b, c); print(c); return 0; }
void enacct(char *as) { struct stime timbuf; struct { char cname[14]; char shf; char uid; int datet[2]; int realt[2]; int bcput[2]; int bsyst[2]; } tbuf; int i; char *np, *s; s = as; times(&timbuf); time(timbuf.proct); lsub(tbuf.realt, timbuf.proct, timeb.proct); lsub(tbuf.bcput, timbuf.cputim, timeb.cputim); lsub(tbuf.bsyst, timbuf.systim, timeb.systim); do { np = s; while (*s != '\0' && *s != '/') s++; } while (*s++ != '\0'); for (i=0; i<14; i++) { tbuf.cname[i] = *np; if (*np) np++; } tbuf.datet[0] = timbuf.proct[0]; tbuf.datet[1] = timbuf.proct[1]; tbuf.uid = uid; tbuf.shf = 0; if (promp==0) tbuf.shf = 1; seek(acctf, 0, 2); write(acctf, &tbuf, sizeof(tbuf)); }