Newsgroups: comp.os.msdos.djgpp Subject: Re: simple thing From: vischne AT ibm DOT net-nospam (root) Organization: The Light References: <34455CCF DOT 41C6 AT jcu DOT edu DOT au> MIME-Version: 1.0 Content-Type: Text/Plain; charset=US-ASCII NNTP-Posting-Host: 32.100.34.229 Message-ID: <3445830d.0@news3.ibm.net> Date: 16 Oct 97 02:59:25 GMT Lines: 34 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <34455CCF DOT 41C6 AT jcu DOT edu DOT au>, Oon DOT Lin AT jcu DOT edu DOT au says... > >Hi ! > >I was doing a simple printf but it seems like I don't get the result I >want... > >The statement was : > > printf("Vertical Retrace Time = %f \n", 1/70) ; > > >I was careful to use '\n' to force the statement above to be printed out >but what I got was > > Vertical Retrace Time = 0.000000 > > >Wha ??? > > >When I cast the calculation > > printf("Vertical Retrace Time = %f \n", (float)(1/70)) ; > >I got the result that I want.... > >Is this a bug in GNU ?? > No, it's a feature in C. You're dealing with a variable length, untyped, argument list. Without the cast to ensure you get a float of the proper type for the format string, anything can happen, and generally does, in all C compilers.