Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!gem.mps.ohio-state.edu!rpi!leah!rds95 From: rds95@leah.Albany.Edu (Robert Seals) Newsgroups: comp.sys.ibm.pc Subject: Bug in Turbo C "printf"; potentially serious. I think. Keywords: rounding, I better be right Message-ID: <2158@leah.Albany.Edu> Date: 13 Nov 89 18:48:02 GMT Organization: The University at Albany, Computer Services Center Lines: 36 Hello, [I was considering posting this to comp.lang.c, but there has been a generally poor response to system specific discussion there...especially about pcs.] Consider this program: /* * A program */ #include void main(void) { double g = 9.6; printf("%lf %.0lf %.1lf\n", g, g, g); } /* * end of a program */ I think that this should result in the line "9.600000 10 9.6\n" being printed on standard output. Turbo C in the small model prints "1" instead of "10"; it seems that whenever the print format is "%.0lf" and the argument rounds to a power of 10, printf and fprintf (haven't tried cprintf or sprintf) print 1 too few '0's. This is bad news. Workaround: Don't use "%.0lf"!!! rob