Hi
I am working on a program which writes the output a SQL select statements from number of source tables first to a load matrix and then writes to a load.dat file.
But while writing to the load.dat file, the program gets stuck if I am putting float variables getting rounded to 8 or 9 decimal places.
But runs fine if the float variable getting rounded to 6 decimal places.
The code snippet is below:
sprintf(outbuf, "%s/work/load.dat",SumHome);
if((fp_tmp=
fopen(outbuf,"w "))==NULL) {
p_std_err("work file could not be opened for write\n");
ErrorExit();
case ORATYPE_FLOAT:
if(p_CurCol->NullFlag) sprintf(EndStri ng(outbuf),"%c" ,Delim);
else{
sprintf(EndStri ng(outbuf),"%10.9f%c",
*(double *)p_CurCol->DataLoc,Delim) ;
}
break;
When I am putting %f ,the program is running fine.But when I put as 9 decimal places i,e %10.9f ,the program is getting stuck.
Can anyone tell me if there is any relation between sprintf and precision of float variables. And why the program is getting stuck.
Is there a limit on the size of the buffer.
I am working on a program which writes the output a SQL select statements from number of source tables first to a load matrix and then writes to a load.dat file.
But while writing to the load.dat file, the program gets stuck if I am putting float variables getting rounded to 8 or 9 decimal places.
But runs fine if the float variable getting rounded to 6 decimal places.
The code snippet is below:
sprintf(outbuf, "%s/work/load.dat",SumHome);
if((fp_tmp=
fopen(outbuf,"w "))==NULL) {
p_std_err("work file could not be opened for write\n");
ErrorExit();
case ORATYPE_FLOAT:
if(p_CurCol->NullFlag) sprintf(EndStri ng(outbuf),"%c" ,Delim);
else{
sprintf(EndStri ng(outbuf),"%10.9f%c",
*(double *)p_CurCol->DataLoc,Delim) ;
}
break;
When I am putting %f ,the program is running fine.But when I put as 9 decimal places i,e %10.9f ,the program is getting stuck.
Can anyone tell me if there is any relation between sprintf and precision of float variables. And why the program is getting stuck.
Is there a limit on the size of the buffer.
Comment