home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 1
/
FishNMoreVol1.bin
/
more
/
code_examples
/
librar
/
ffloat.c
< prev
next >
Wrap
Text File
|
1989-02-08
|
2KB
|
62 lines
/*--------------------------------------*/
/* */
/* FFLOAT(X,X,X,X,X,X) */
/* */
/* Writes a floating point number to a */
/* file The first argument is the file */
/* descripter. The second argument is */
/* the number to be written to file. */
/* The third argument is the number of */
/* of places needed to be filled left */
/* of the decimal point. The fourth */
/* argument is the number of places */
/* needed to be filled right of the */
/* decimal point. The fifth argument */
/* is a flag for space(1) or zero(0) */
/* filler. The sixth argument is the */
/* flag determining if a CRLF is to be */
/* added to the file(0 is no, 1 is yes.)*/
/* */
/*--------------------------------------*/
# include "stdio.h"
void ffloat(fd,flote,a,b,cc,d)
float flote;
int a,b,cc,d;
FILE *fd;
{
int j;
char c[5];
double dd,ee,bb,pow();
float ff;
bb=10;
a--;
if (a>0){
for (j=a;j>0;j--){
if (j==a){
if (flote<0){
putc(45,fd);
flote*=-1.0;
}
else
putc(32,fd);
}
ee=j;
ff=dd=pow(bb,ee);
if (flote<ff){
if (!cc)
putc(48,fd);
else
putc(32,fd);
}
}
}
c[0]='%';
c[1]='.';
c[2]=b+48;
c[3]='f';
c[4]=0;
fprintf(fd,c,flote);
if (d==1)
fcrlf(fd,1);
}