Annotation of 41BSD/cmd/lisp/pbignum.c, revision 1.1

1.1     ! root        1: static char *sccsid = "@(#)pbignum.c   34.1 10/3/80";
        !             2: 
        !             3: #include "global.h"
        !             4: 
        !             5: pbignum(current, useport)
        !             6: register lispval current;
        !             7: register FILE *useport;
        !             8: {
        !             9:        int  *top, *bot, *work, negflag = 0, *sp(), *alloca();
        !            10:        register int *digitp, *binp;
        !            11:        register lispval last;
        !            12: 
        !            13:        /* copy bignum onto stack */
        !            14:        top = sp() - 1;
        !            15:        do {
        !            16:                stack(current->s.I);
        !            17:        } while(current = current->s.CDR);
        !            18: 
        !            19:        bot = sp();
        !            20:        if (top==bot) {
        !            21:                fprintf(useport,"%d",*bot);
        !            22:                return;
        !            23:        }
        !            24: 
        !            25:        /* save space for printed digits*/
        !            26:        work = alloca((top-bot)*2*sizeof(int));
        !            27:        if( *bot < 0) {
        !            28:                negflag = 1;
        !            29:                dsneg(top,bot);
        !            30:        }
        !            31: 
        !            32:        /* figure out nine digits at a time by destructive division*/
        !            33:        for(digitp = work; bot <= top; digitp++) {
        !            34:                *digitp = dodiv(top,bot);
        !            35:                if(*bot==0) bot += 1;
        !            36:        }
        !            37:        
        !            38:        /* print them out */
        !            39: 
        !            40:        if(negflag) putc('-',useport);
        !            41:        fprintf(useport,"%d",*--digitp);
        !            42:        while ( digitp > work) fprintf(useport,"%09d",*--digitp);
        !            43: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.