<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Mayday Programming Brain Teaser</title>
	<atom:link href="http://adammonsen.com/post/337/feed" rel="self" type="application/rss+xml" />
	<link>http://adammonsen.com/post/337</link>
	<description>blog and sundries of Adam Monsen</description>
	<pubDate>Sat, 05 Jul 2008 21:19:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Jason</title>
		<link>http://adammonsen.com/post/337#comment-11788</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Fri, 02 May 2008 03:17:12 +0000</pubDate>
		<guid isPermaLink="false">http://adammonsen.com/post/337#comment-11788</guid>
		<description>I would guess that the result in C was dependent on how closely the compiler follows operator precedence/binding. 

The postfix increment operator "++" is at the top of the precedence chart where direct assignment "=" is almost at the bottom. 

Wouldn't CPP turn it into: 

k = (k++)

and not:

k = k;
k++;

?? 

Then I found this:

"Postfix increment/decrement have high precedence, but the actual increment or decrement of the operand is delayed (to be accomplished sometime before the statement completes execution). So in the statement  y = x * z++;  the current value of z is used to evaluate the expression (i.e.,  z++  evaluates to z) and z only incremented after all else is done."

I couldn't locate a copy of the ANSI C standard in the 5 min. I spent looking... 

YMMV. Darn!</description>
		<content:encoded><![CDATA[<p>I would guess that the result in C was dependent on how closely the compiler follows operator precedence/binding. </p>
<p>The postfix increment operator &#8220;++&#8221; is at the top of the precedence chart where direct assignment &#8220;=&#8221; is almost at the bottom. </p>
<p>Wouldn&#8217;t CPP turn it into: </p>
<p>k = (k++)</p>
<p>and not:</p>
<p>k = k;<br />
k++;</p>
<p>?? </p>
<p>Then I found this:</p>
<p>&#8220;Postfix increment/decrement have high precedence, but the actual increment or decrement of the operand is delayed (to be accomplished sometime before the statement completes execution). So in the statement  y = x * z++;  the current value of z is used to evaluate the expression (i.e.,  z++  evaluates to z) and z only incremented after all else is done.&#8221;</p>
<p>I couldn&#8217;t locate a copy of the ANSI C standard in the 5 min. I spent looking&#8230; </p>
<p>YMMV. Darn!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://adammonsen.com/post/337#comment-11787</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Fri, 02 May 2008 00:30:48 +0000</pubDate>
		<guid isPermaLink="false">http://adammonsen.com/post/337#comment-11787</guid>
		<description>The system/application admin says:

Because some parsers see ++ as a sequential step to perform after the items before it.

"the variable k is equal to the variable k.  now increment k by one."

In some languages this can be solved by writing the code like this:

k = ++k;

Which translates to "the variable k is equal to the incremented value of k."

Or I could be completely wrong... :-)</description>
		<content:encoded><![CDATA[<p>The system/application admin says:</p>
<p>Because some parsers see ++ as a sequential step to perform after the items before it.</p>
<p>&#8220;the variable k is equal to the variable k.  now increment k by one.&#8221;</p>
<p>In some languages this can be solved by writing the code like this:</p>
<p>k = ++k;</p>
<p>Which translates to &#8220;the variable k is equal to the incremented value of k.&#8221;</p>
<p>Or I could be completely wrong&#8230; <img src='http://adammonsen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
