1987-03-31 10:45:53 +00:00
|
|
|
/* $Header$ */
|
1987-01-27 15:57:55 +00:00
|
|
|
#ifndef NOFLOAT
|
|
|
|
extern char *fcvt();
|
|
|
|
extern char *ecvt();
|
|
|
|
|
|
|
|
char *
|
|
|
|
_pfloat(r,s,n,b)
|
|
|
|
double r;
|
|
|
|
register char *s;
|
|
|
|
{
|
1987-05-25 09:13:12 +00:00
|
|
|
register char *s1;
|
|
|
|
int sign,dp;
|
|
|
|
register int i;
|
1987-01-27 15:57:55 +00:00
|
|
|
|
|
|
|
if (b == 0)
|
|
|
|
n = 6;
|
|
|
|
s1 = fcvt(r,n,&dp,&sign);
|
|
|
|
if (sign)
|
|
|
|
*s++ = '-';
|
|
|
|
if (dp<=0)
|
|
|
|
*s++ = '0';
|
|
|
|
for (i=dp; i>0; i--)
|
1987-10-22 15:26:36 +00:00
|
|
|
if (*s1) *s++ = *s1++;
|
|
|
|
else *s++ = '0';
|
1987-01-27 15:57:55 +00:00
|
|
|
if ((i=n) > 0)
|
|
|
|
*s++ = '.';
|
|
|
|
while (++dp <= 0) {
|
|
|
|
if (--i<0)
|
|
|
|
break;
|
|
|
|
*s++ = '0';
|
|
|
|
}
|
|
|
|
while (--i >= 0)
|
1987-10-22 15:26:36 +00:00
|
|
|
if (*s1) *s++ = *s1++;
|
|
|
|
else *s++ = '0';
|
1987-01-27 15:57:55 +00:00
|
|
|
return(s);
|
|
|
|
}
|
|
|
|
|
1987-05-25 09:13:12 +00:00
|
|
|
char *_pscien(r,s,n,b) float r; register char *s; {
|
|
|
|
int sign,dp;
|
|
|
|
register char *s1;
|
1987-01-27 15:57:55 +00:00
|
|
|
|
|
|
|
if (b == 0)
|
|
|
|
n = 7;
|
|
|
|
else n += 1;
|
|
|
|
s1 = ecvt(r,n,&dp,&sign);
|
|
|
|
if (sign)
|
|
|
|
*s++ = '-';
|
|
|
|
*s++ = *s1++;
|
|
|
|
*s++ = '.';
|
|
|
|
while (--n>0)
|
1987-10-22 15:26:36 +00:00
|
|
|
if (*s1) *s++ = *s1++;
|
|
|
|
else *s++ = '0';
|
1987-01-27 15:57:55 +00:00
|
|
|
*s++ = 'e';
|
|
|
|
if ( r ) --dp ;
|
|
|
|
if ( dp<0 ) {
|
|
|
|
*s++ = '-' ; dp= -dp ;
|
|
|
|
} else {
|
|
|
|
*s++ = '+' ;
|
|
|
|
}
|
1988-07-01 11:56:08 +00:00
|
|
|
if (dp >= 100) {
|
|
|
|
*s++ = '0' + (dp / 100);
|
|
|
|
dp %= 100;
|
|
|
|
}
|
1987-01-27 15:57:55 +00:00
|
|
|
*s++ = '0' + (dp/10);
|
|
|
|
*s++ = '0' + (dp%10);
|
|
|
|
return(s);
|
|
|
|
}
|
|
|
|
#endif
|