void dcprint(Blk *hptr) { Blk *p, *q, *dec; int dig, dout, ct, sc; rewind(hptr); while(sfeof(hptr) == 0) { if(sgetc(hptr)>99) { rewind(hptr); while(sfeof(hptr) == 0) { Bprint(&bout,"%c",sgetc(hptr)); } Bprint(&bout,"\n"); return; } } fsfile(hptr); sc = sbackc(hptr); if(sfbeg(hptr) != 0) { Bprint(&bout,"0\n"); return; } count = ll; p = copy(hptr,length(hptr)); sclobber(p); fsfile(p); if(sbackc(p)<0) { chsign(p); OUTC('-'); } if((obase == 0) || (obase == -1)) { oneot(p,sc,'d'); return; } if(obase == 1) { oneot(p,sc,'1'); return; } if(obase == 10) { tenot(p,sc); return; } /* sleazy hack to scale top of stack - divide by 1 */ pushp(p); sputc(p, sc); p=salloc(0); create(p); sputc(p, 1); sputc(p, 0); pushp(p); if(dscale() != 0) return; p = div(arg1, arg2); release(arg1); release(arg2); sc = savk; create(strptr); dig = logten*sc; dout = ((dig/10) + dig) / logo; dec = getdec(p,sc); p = removc(p,sc); while(length(p) != 0) { q = div(p,basptr); release(p); p = q; (*outdit)(rem,0); } release(p); fsfile(strptr); while(sfbeg(strptr) == 0) OUTC(sbackc(strptr)); if(sc == 0) { release(dec); Bprint(&bout,"\n"); return; } create(strptr); OUTC('.'); ct=0; do { q = mult(basptr,dec); release(dec); dec = getdec(q,sc); p = removc(q,sc); (*outdit)(p,1); } while(++ct < dout); release(dec); rewind(strptr); while(sfeof(strptr) == 0) OUTC(sgetc(strptr)); Bprint(&bout,"\n"); }
void print(struct blk *hptr) { int sc; register struct blk *p,*q,*dec; int dig,dout,ct; rewind(hptr); while(sfeof(hptr) == 0){ if(sgetc(hptr)>99){ rewind(hptr); while(sfeof(hptr) == 0){ printf("%c",sgetc(hptr)); } printf("\n"); return; } } fsfile(hptr); sc = sbackc(hptr); if(sfbeg(hptr) != 0){ printf("0\n"); return; } count = ll; p = copy(hptr,length(hptr)); sunputc(p); fsfile(p); if(sbackc(p)<0){ chsign(p); OUTC('-'); } if((obase == 0) || (obase == -1)){ oneot(p,sc,'d'); return; } if(obase == 1){ oneot(p,sc,'1'); return; } if(obase == 10){ tenot(p,sc); return; } create(strptr); dig = log_10*sc; dout = ((dig/10) + dig) /logo; dec = getdec(p,sc); p = removc(p,sc); while(length(p) != 0){ q = dcdiv(p,basptr); release(p); p = q; (*outdit)(rem,0,1); } release(p); fsfile(strptr); while(sfbeg(strptr) == 0)OUTC(sbackc(strptr)); if(sc == 0){ release(dec); printf("\n"); return; } create(strptr); OUTC('.'); ct=0; do{ q = mult(basptr,dec); release(dec); dec = getdec(q,sc); p = removc(q,sc); (*outdit)(p,1,ct+1<dout); }while(++ct < dout); release(dec); rewind(strptr); while(sfeof(strptr) == 0)OUTC(sgetc(strptr)); printf("\n"); return; }