1: /* Fortran convert number to string. PLWard 3/20/80 */
2: #define BUFLEN 50
3: #define MAXPREC 40
4: #define EXPPLUS 1000
5:
6: char numstr_(out,len,num,prec)
7: char out[];
8: long len;
9: int *prec;
10: float *num;
11: {
12: char fmt[10];
13: int precx,precy=0;
14: int i,j,lenbuf;
15: int dot = -1;
16: char type='f';
17: char buf[BUFLEN];
18:
19: precx = *prec;
20: if (precx > EXPPLUS - 2 ) { precx=precx - EXPPLUS; type = 'e'; }
21: if (precx < 0 ) { precy = precx; precx = 0; }
22: if (precx > MAXPREC) precx = MAXPREC;
23:
24: sprintf(fmt,"%%.%d%c",precx,type);
25: sprintf(buf,fmt,*num);
26:
27: for(lenbuf=0; buf[lenbuf] != '\0'; lenbuf++)
28: if(buf[lenbuf] == '.' && *prec == EXPPLUS-1) dot=lenbuf;
29: if (precx == 0 && type == 'f') buf[lenbuf++]='.';
30: if (*prec < 0 ) lenbuf =(dot > -1) ? dot+precy+1 : lenbuf+precy;
31: for(i=j=0; i<len;i++)
32: if (j >= lenbuf) out[j++]=' ';
33: else if ( i != dot ) out[j++]=buf[i];
34: }
Defined functions
Defined macros
BUFLEN
defined in line
2; used 1 times