Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!ucsd!ogccse!orstcs!jacobs.CS.ORST.EDU!moorer From: moorer@jacobs.CS.ORST.EDU (Rocky Moore) Newsgroups: comp.sys.ibm.pc Subject: Re: Bug in Turbo C "printf"; potentially serious. I think. Keywords: rounding, I better be right Message-ID: <13803@orstcs.CS.ORST.EDU> Date: 15 Nov 89 13:39:26 GMT References: <2158@leah.Albany.Edu> Sender: usenet@orstcs.CS.ORST.EDU Reply-To: moorer@jacobs.CS.ORST.EDU.UUCP (Rocky Moore) Organization: Oregon State University - CS - Corvallis Oregon Lines: 21 In article <2158@leah.Albany.Edu> you write: > >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 The problem is certainly a bug. It only happens (in any model) when you have a number which when rounded off will increase the number of leading digits ( e.g. 999.9 9999.9 99.9 ect).. You should also note note to EVER forget to include math.h if you use something like the sine() or cos() functions. You will find that the printf() will seem to print just junk at times instead of the values supplied. It can cost you many hours of debugging when you have just forogt a header file. -Rocky Moore moorer@jacobs.cs.orst.edu - Let those who ride decide!