Re: C programming
I suggest going to comp.lang.c and checking the C FAQ. Specifically look
for the inherent problem of putting the same variable on both sides of a
relational operator: (x+y) > x
If memory serves, the behavior is "undefined" -- so don't do it!
On Fri, Aug 04, 2000 at 11:55:36PM +0200, Christophe TROESTLER wrote:
> Hi the list,
>
> I apologize if that is a little bit off topic but I am a bit puzzled
> and I know there are experts on this list. I would like an
> explanation on why the two "for" below give different results.
>
> Thanks,
> ChriS
>
>
> -.¸¸.·´¯`·.¸¸.-.¸¸.·´¯`·.¸¸.-.¸¸.·´¯`·.¸¸.-.¸¸.·´¯`·.¸¸.-.¸¸.·´¯`·.¸¸.-
>
>
> #include <stdio.h>
>
> main()
> {
> double x, y, z;
> int t;
>
> for(x=.5, y=1./4., t=1; z= x + y, z > x; y /=2, t++)
> ;
> printf("t=%i\n", t);
>
> for(x=.5, y=1./4., t=1; x+y > x; y /=2, t++)
> ;
> printf("t=%i\n", t);
> }
>
>
> --
> Unsubscribe? mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null
>
>
--
MegaHAL quote:
I think a blowpipe is a marijuana cigarrette.
It'll get you deleted!
Reply to:
- References:
- C programming
- From: Christophe TROESTLER <Ch.Troestler@linkline.be>