Mail Archives: djgpp/1998/05/31/13:01:46
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 |
---------------------------------------------------------------------
- Raw text -