From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: A nice trap! (2) Date: Sun, 31 May 1998 12:41:37 -0400 Organization: Two pounds of chaos and a pinch of salt. Lines: 26 Message-ID: <35718841.1129@cs.com> References: <35715AA9 DOT 4222FD24 AT net4you DOT co DOT at> NNTP-Posting-Host: ppp120.cs.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Seawolf wrote: > > Now try: > f = 10 / 1.1; > > Funny!? Is this a trick question? The first program prints 0.000000, the second prints 9.090909. Any C tutorial should tell you the difference between integer and floating point division and the rules of implicit type promotion. BTW, your test program has some significant flaws. First, main() must return an integer according to the ANSI standard. Second, library functions like printf() must be prototyped by including the appropriate standard header file, in this case stdio.h. If you compile your program with '-Wall', you'll see these flagged as warnings. Even test code should conform to the rules of the language. -- --------------------------------------------------------------------- | John M. Aldrich | "A committee is a life form with six | | aka Fighteer I | or more legs and no brain." | | mailto:fighteer AT cs DOT com | | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------