bug in _doprnt
Ralph Freudenberger
freuden at gryphon.CTS.COM
Mon Mar 7 06:28:44 AEST 1988
I just discovered a bug with the _doprnt procedure responsible for
library functions such as printf, sprintf, etc.
It seems that there is an inconsistency in the way the unix-pc rounds
off floating point numbers through _doprnt.
If one runs the following rough program and give the following input:
0.4750
one will get 0.47 as output.
But when one gives 0.4650 as input one receives 0.47 as output.....
very peculiar.
ralph f.
#######################################
main()
{
char buf[10];
double f, atof();
while (1) {
printf("\ntype> ");
scanf("%s",buf);
f = atof(buf);
printf("f is %f\n",f);
sprintf(buf,"%.2f",f);
printf("\nafter <%s>\n",buf);
}
}
More information about the Unix-pc.general
mailing list