Path: utzoo!utgpu!water!watmath!uunet!lll-winken!gryphon!freuden From: freuden@gryphon.CTS.COM (Ralph Freudenberger) Newsgroups: unix-pc.general Subject: bug in _doprnt Keywords: sprintf,_doprnt,printf Message-ID: <2788@gryphon.CTS.COM> Date: 6 Mar 88 20:28:44 GMT Organization: Trailing Edge Technology, Redondo Beach, Ca. Lines: 34 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); } }