Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: unbelievable "simple" question/bug? Message-ID: <17989@crdgw1.crd.ge.com> Date: 28 Mar 91 16:56:24 GMT References: <8331@umd5.umd.edu> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Distribution: na Lines: 30 In article <8331@umd5.umd.edu>, jjk@jupiter.astro.umd.edu (Jim Klavetter) writes: |>It isn't precedence or some side effect, it is just weird. I have the |>code fragment (a, b, c, integers) |> |> if(a-b-c>0) |> do ifstuff |> else |> do elsestuff |> |>When a=b=c=1 the above should translate to if(-1>0) and the elsestuff |>should get done. It doesn't. I tried putting parens around (a-b-c) |>(which should be unnecessaray) and it didn't make any difference. OK, |>now here is the real weird part: if I have the following: |> temp=a-b-c; |> if(temp>0) |> do ifstuff |> else |> do elsestuff |>it works as expected! Anybody want to tell me what I'm missing? Are you sure they are all ints? If one of either a or b or c is really an UNSIGNED int, then a-b-c would be some big positive number, which would explain the first example. If temp is an int, then putting that big positive integer back in temp would do what you want, since temp would then have the value -1. ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com