Newsgroups: comp.sys.amiga.programmer
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!maize.engin.umich.edu!milamber
From: milamber@caen.engin.umich.edu (Daryl Cantrell)
Subject: Re: Compiler code (was a flame fest) (now a lesser flame fest)
Message-ID: <1991Apr19.032052.26387@engin.umich.edu>
Sender: news@engin.umich.edu (CAEN Netnews)
Organization: University of Michigan Engineering, Ann Arbor
References: <1991Apr17.180342.25312@engin.umich.edu> <1991Apr18.122054.13695@athena.mit.edu> <1991Apr18.212939.3461@kessner.denver.co.us>
Date: Fri, 19 Apr 1991 03:20:52 GMT

In article <1991Apr18.212939.3461@kessner.denver.co.us> david@kessner.denver.co.us (David Kessner) writes:
>In article <1991Apr18.122054.13695@athena.mit.edu> amgreene@athena.mit.edu (Andrew Marc Greene) writes:
>>Oh, but it *is* useful!  What is the value of the following code
>>fragment?
>>
>>  int n = 4;
>>
>>  (++n) * (--n);
>>
>>If the first operand to * is treated first, the answer is 20.  If the
>>second operand to * is treated first, the answer is 12.  
>>
>>-- Andrew <amgreene@mit.edu> | .sigs are for people with bandwidth to burn

  And such a useful expression, too.  Really.

>Humph.  The answer is 16.
>
>The pre-operators (--n ++n) mean "evaluate these expressions before anything
>else".  So the above statement is the same as:
>
>	n=n+1;
>	n=n-1;
>	?? = n * n;
>
>Try it.
>
>-- 
>David Kessner - david@kessner.denver.co.us            | do {
>1135 Fairfax, Denver CO  80220  (303) 377-1801 (p.m.) |    . . .
>If you cant flame MS-DOS, who can you flame?          |    } while( jones);

  Nope.  ++ and -- are unary operators of the highest precedence.  The only
difference between ++x and x++ is the value they assume, the order of eval-
uation follows standard C precedence..


--
+---------------------------------------+----------------------------+
|   // Daryl S. Cantrell                |   These opinions are       |
| |\\\ milamber@caen.engin.umich.edu    |    shared by all of    //  |
| |//  Evolution's over.  We won.       |        Humanity.     \X/   |
+---------------------------------------+----------------------------+
