|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include "mp.h" ! 3: double modf(); ! 4: char obuf[200]; ! 5: ! 6: ! 7: void ! 8: mout(a) ! 9: mint a; ! 10: { ! 11: m_out(a, 10, stdout); ! 12: printf("\n"); ! 13: } ! 14: void ! 15: mout1(a) ! 16: mint a; ! 17: { ! 18: m_out(a,10,stdout); ! 19: } ! 20: ! 21: m_out(a,b,f) ! 22: mint a; ! 23: int b; ! 24: FILE *f; ! 25: { ! 26: int sign; ! 27: double carry, temp2; ! 28: mint x; ! 29: char *bp; ! 30: ! 31: x = a; ! 32: sign = 1; ! 33: bp = &obuf[199]; ! 34: if((x.high==0) && (x.low==0)){ ! 35: printf("0"); ! 36: return; ! 37: } ! 38: *bp-- = 0; ! 39: if(x.high<0){ ! 40: x.high = -x.high; ! 41: sign = -1; ! 42: } ! 43: if(x.low<0){ ! 44: x.low = -x.low; ! 45: sign = -1; ! 46: } ! 47: ! 48: while((x.high!=0) || (x.low!=0)){ ! 49: carry = 0; ! 50: if(x.high != 0){ ! 51: carry = modf(x.high/10. , &x.high); ! 52: } ! 53: temp2 = modf(x.low/10. , &x.low); ! 54: x.low += (int)(10.*carry+0.5) * e15; ! 55: *bp-- = (int)(10.*temp2+0.5) + '0'; ! 56: } ! 57: if(sign<0) ! 58: *bp-- = '-'; ! 59: bp++; ! 60: fprintf(f,"%s",bp); ! 61: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.