<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for Stack Overflow</title>
	<atom:link href="http://embeddedgurus.com/stack-overflow/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedgurus.com/stack-overflow</link>
	<description>Thoughts on embedded systems by Nigel Jones</description>
	<lastBuildDate>Wed, 08 Feb 2012 01:35:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>Comment on The absolute truth about abs() by Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2012/02/the-absolute-truth-about-abs/comment-page-1/#comment-14140</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Wed, 08 Feb 2012 01:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=772#comment-14140</guid>
		<description>Thanks for comment Ken. While I agree about checking return values, in the case I&#039;m describing it is *not* guaranteed to work. The result of passing INT_MIN to abs() is *undefined*. With the one compiler I tried it returned a negative number. Another compiler may return 0, or INT_MAX, or indeed any value between INT_MIN and INT_MAX. Thus blithely checking the return value is non-negative is pointless unless you know for sure what your compiler does and are prepared to run the risk of the code being ported to a different platform down the road. This really is a case where you need to check your inputs.</description>
		<content:encoded><![CDATA[<p>Thanks for comment Ken. While I agree about checking return values, in the case I&#8217;m describing it is *not* guaranteed to work. The result of passing INT_MIN to abs() is *undefined*. With the one compiler I tried it returned a negative number. Another compiler may return 0, or INT_MAX, or indeed any value between INT_MIN and INT_MAX. Thus blithely checking the return value is non-negative is pointless unless you know for sure what your compiler does and are prepared to run the risk of the code being ported to a different platform down the road. This really is a case where you need to check your inputs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The absolute truth about abs() by Ken</title>
		<link>http://embeddedgurus.com/stack-overflow/2012/02/the-absolute-truth-about-abs/comment-page-1/#comment-14112</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Tue, 07 Feb 2012 12:09:55 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=772#comment-14112</guid>
		<description>I don&#039;t see a problem with the current definition of abs.  It returns a signed integer.  It seems obvious to me that if a negative number is returned, there is a problem.  Return values should always be checked.  I believe that you are making a big deal out of something trivial.  

However, I am willing to play the game.  Let&#039;s say it was explicitly checking for INT_MIN.  How should it alert the user?  The only option for its prototype is to return a negative number; upon further inspection, it does just that when improper input is tried.  The only way I could advocate the duplication of abs functionality is if you wanted to force the user to check for error conditions by changing the interface of the function to something along the lines of the following. 

 int abs(int input, int *output);  
Where a return value of zero implies success; otherwise errno is returned.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t see a problem with the current definition of abs.  It returns a signed integer.  It seems obvious to me that if a negative number is returned, there is a problem.  Return values should always be checked.  I believe that you are making a big deal out of something trivial.  </p>
<p>However, I am willing to play the game.  Let&#8217;s say it was explicitly checking for INT_MIN.  How should it alert the user?  The only option for its prototype is to return a negative number; upon further inspection, it does just that when improper input is tried.  The only way I could advocate the duplication of abs functionality is if you wanted to force the user to check for error conditions by changing the interface of the function to something along the lines of the following. </p>
<p> int abs(int input, int *output);<br />
Where a return value of zero implies success; otherwise errno is returned.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Novel uses for RTC registers by Daryl</title>
		<link>http://embeddedgurus.com/stack-overflow/2011/12/novel-uses-for-rtc-registers/comment-page-1/#comment-14103</link>
		<dc:creator>Daryl</dc:creator>
		<pubDate>Tue, 07 Feb 2012 03:57:29 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=646#comment-14103</guid>
		<description>Clever, except again this is using some &#039;trick&#039; to achieve what should be a basic feature for any MCU, to be able to command a reset intentionally that the processor recognizes as an intentional reset with user enumerated cause.  Really, let&#039;s just keep this obvious and to the point.  You want to reset and you get a byte to tell yourself why.  Justification for such a simple thing should be obvious to any chip designer. I mean what percent of embedded code out there uses a watchdog reset to do something that really should be done using a facility like this? &gt;90 for sure.</description>
		<content:encoded><![CDATA[<p>Clever, except again this is using some &#8216;trick&#8217; to achieve what should be a basic feature for any MCU, to be able to command a reset intentionally that the processor recognizes as an intentional reset with user enumerated cause.  Really, let&#8217;s just keep this obvious and to the point.  You want to reset and you get a byte to tell yourself why.  Justification for such a simple thing should be obvious to any chip designer. I mean what percent of embedded code out there uses a watchdog reset to do something that really should be done using a facility like this? &gt;90 for sure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Efficient C Tip #12 &#8211; Be wary of switch statements by Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/04/efficient-c-tip-12-be-wary-of-switch-statements/comment-page-1/#comment-14095</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Tue, 07 Feb 2012 01:00:12 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=450#comment-14095</guid>
		<description>You are most welcome.</description>
		<content:encoded><![CDATA[<p>You are most welcome.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Efficient C Tip #12 &#8211; Be wary of switch statements by Raul</title>
		<link>http://embeddedgurus.com/stack-overflow/2010/04/efficient-c-tip-12-be-wary-of-switch-statements/comment-page-1/#comment-14077</link>
		<dc:creator>Raul</dc:creator>
		<pubDate>Mon, 06 Feb 2012 17:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=450#comment-14077</guid>
		<description>Mr. Jones,

Thank you for sharing your knowledge and experience.

I read all 12 tips and learnt a lot!</description>
		<content:encoded><![CDATA[<p>Mr. Jones,</p>
<p>Thank you for sharing your knowledge and experience.</p>
<p>I read all 12 tips and learnt a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The absolute truth about abs() by pozz</title>
		<link>http://embeddedgurus.com/stack-overflow/2012/02/the-absolute-truth-about-abs/comment-page-1/#comment-14053</link>
		<dc:creator>pozz</dc:creator>
		<pubDate>Mon, 06 Feb 2012 08:07:27 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=772#comment-14053</guid>
		<description>Is it sufficient to write

  return (unsigned) (i &lt; 0 ? -i : i);

or have I to write:

  return  (i &lt; 0 ? -(unsigned)i : i);

??</description>
		<content:encoded><![CDATA[<p>Is it sufficient to write</p>
<p>  return (unsigned) (i &lt; 0 ? -i : i);</p>
<p>or have I to write:</p>
<p>  return  (i &lt; 0 ? -(unsigned)i : i);</p>
<p>??</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The absolute truth about abs() by Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2012/02/the-absolute-truth-about-abs/comment-page-1/#comment-13977</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Sat, 04 Feb 2012 23:52:05 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=772#comment-13977</guid>
		<description>I&#039;m not sure what you are asking David. Regarding - INT_MIN. If INT_MIN is defined correctly with parentheses, then -INT_MIN  becomes on a 16 bit processor -(-32768) = + 32768 , which in turn overflows a signed 16 bit integer. If the definer of INT_MIN has been sloppy and omitted the parentheses, then -INT_MIN becomes --32768! I shudder to think what happens in this case.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure what you are asking David. Regarding &#8211; INT_MIN. If INT_MIN is defined correctly with parentheses, then -INT_MIN  becomes on a 16 bit processor -(-32768) = + 32768 , which in turn overflows a signed 16 bit integer. If the definer of INT_MIN has been sloppy and omitted the parentheses, then -INT_MIN becomes &#8211;32768! I shudder to think what happens in this case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The absolute truth about abs() by david collier</title>
		<link>http://embeddedgurus.com/stack-overflow/2012/02/the-absolute-truth-about-abs/comment-page-1/#comment-13940</link>
		<dc:creator>david collier</dc:creator>
		<pubDate>Sat, 04 Feb 2012 09:53:50 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=772#comment-13940</guid>
		<description>Nigel - leaving aside the lack of range-checking - is my point about unary minus valid, and not amenable to the strategies suggested for ABS ?</description>
		<content:encoded><![CDATA[<p>Nigel &#8211; leaving aside the lack of range-checking &#8211; is my point about unary minus valid, and not amenable to the strategies suggested for ABS ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The absolute truth about abs() by david collier</title>
		<link>http://embeddedgurus.com/stack-overflow/2012/02/the-absolute-truth-about-abs/comment-page-1/#comment-13939</link>
		<dc:creator>david collier</dc:creator>
		<pubDate>Sat, 04 Feb 2012 09:51:42 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=772#comment-13939</guid>
		<description>Jeff - what&#039;s more you have to work carefully to ensure that your FFFF in 16 bits turns into FFFFFFFF in 32 - it&#039;s quite easy to end up with 0000FFFF.</description>
		<content:encoded><![CDATA[<p>Jeff &#8211; what&#8217;s more you have to work carefully to ensure that your FFFF in 16 bits turns into FFFFFFFF in 32 &#8211; it&#8217;s quite easy to end up with 0000FFFF.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The absolute truth about abs() by Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2012/02/the-absolute-truth-about-abs/comment-page-1/#comment-13903</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Fri, 03 Feb 2012 20:31:53 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/stack-overflow/?p=772#comment-13903</guid>
		<description>I&#039;m inclined to agree. I have always found it curious that abs() returns a signed value. However, it seems like the authors of the C library considered unsigned integers an annoyance, and thus used them as sparingly as possible.</description>
		<content:encoded><![CDATA[<p>I&#8217;m inclined to agree. I have always found it curious that abs() returns a signed value. However, it seems like the authors of the C library considered unsigned integers an annoyance, and thus used them as sparingly as possible.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

