|
|
1.1 ! root 1: double ! 2: ldexp(fr,exp) double fr; int exp;{ ! 3: double huge = 1.701411834604692293e38; ! 4: int neg; ! 5: int i; ! 6: double frexp(); ! 7: ! 8: neg = 0; ! 9: if(fr<0){ ! 10: fr = -fr; ! 11: neg = 1; ! 12: } ! 13: fr = frexp(fr,&i); ! 14: while(fr<.5){ ! 15: fr = 2*fr; ! 16: i = i-1; ! 17: } ! 18: exp = exp+i; ! 19: if(exp>127) ! 20: if(neg) ! 21: return(-huge); ! 22: else ! 23: return(huge); ! 24: if(exp<-127) ! 25: return(0); ! 26: while(exp>30){ ! 27: fr = fr*(1L<<30); ! 28: exp = exp-30; ! 29: } ! 30: while(exp<-30){ ! 31: fr = fr/(1L<<30); ! 32: exp = exp+30; ! 33: } ! 34: if(exp>0) ! 35: fr = fr*(1L<<exp); ! 36: if(exp<0) ! 37: fr = fr/(1L<<-exp); ! 38: if(neg) fr = -fr; ! 39: return(fr); ! 40: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.