Message-ID: <35716E8F.DD3CAE65@ipass.net> From: Terry MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: A nice trap! References: <35715A2E DOT A9A35953 AT net4you DOT co DOT at> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 19 Date: Sun, 31 May 1998 14:43:46 GMT NNTP-Posting-Host: ts3-142-ppp.ipass.net NNTP-Posting-Date: Sun, 31 May 1998 10:43:46 EDT Organization: iPass.Net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Seawolf wrote: > > Do you know this one? > Try it out :-) > > void main( void) > { > float f; > f = 55 / 77; > printf( "%f", f); > } You get 0.0000 of course. 55 and 77 are integers. The result of this integer division is zero which is then converted to float. However, I agree that for novice programmers, this could be a trap and should be changed to f = 55.0 / 77.0; Terry