<?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 on: Knowing my weaknesses</title>
	<atom:link href="http://embeddedgurus.com/stack-overflow/2008/12/knowing-my-weaknesses/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedgurus.com/stack-overflow/2008/12/knowing-my-weaknesses/</link>
	<description>Thoughts on embedded systems by Nigel Jones</description>
	<lastBuildDate>Sun, 06 May 2012 10:34:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2008/12/knowing-my-weaknesses/comment-page-1/#comment-418</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Thu, 04 Mar 2010 11:41:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2008/12/06/knowing-my-weaknesses/#comment-418</guid>
		<description>Hi Greg. I&#039;m afraid your comment got lost in the blogging platform move. Anyway I think I may have already done what you are asking for - please check &lt;a href=&quot;http://embeddedgurus.com/stack-overflow/2007/05/continued-fractions/&quot; rel=&quot;nofollow&quot;&gt;this &lt;/a&gt;out.</description>
		<content:encoded><![CDATA[<p>Hi Greg. I&#8217;m afraid your comment got lost in the blogging platform move. Anyway I think I may have already done what you are asking for &#8211; please check <a href="http://embeddedgurus.com/stack-overflow/2007/05/continued-fractions/" rel="nofollow">this </a>out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Nelson</title>
		<link>http://embeddedgurus.com/stack-overflow/2008/12/knowing-my-weaknesses/comment-page-1/#comment-70</link>
		<dc:creator>Greg Nelson</dc:creator>
		<pubDate>Wed, 24 Feb 2010 22:28:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2008/12/06/knowing-my-weaknesses/#comment-70</guid>
		<description>Nigel,I think you or someone should do a blog post on the related topic of integer approximations for floating point scaling.  I wrote my own little command line utility to get the nearest integer ratio to a given float, up to a given maximum denominator.  I find I use this all the time on non-float capable systems with limited horsepower.For example, you might have a formula that says the actual measurement is 2430/1024 (or equivalently, about 2.37305) times the 10-bit ADC reading.  If you multiply a 10-bit ADC value by 2430, you will overflow your device&#039;s 16-bit integers for many inputs, and of course if you divide by 1024 first, you always underflow.Even if you factor out the greatest common divisor (2) you get 1215/512 with the same problems.  But it turns out that 19/8 approximates this to within 0.08%, or less than one bit.The next better approximation is 83/35, but 83*1023 &gt; 16 bits again.</description>
		<content:encoded><![CDATA[<p>Nigel,I think you or someone should do a blog post on the related topic of integer approximations for floating point scaling.  I wrote my own little command line utility to get the nearest integer ratio to a given float, up to a given maximum denominator.  I find I use this all the time on non-float capable systems with limited horsepower.For example, you might have a formula that says the actual measurement is 2430/1024 (or equivalently, about 2.37305) times the 10-bit ADC reading.  If you multiply a 10-bit ADC value by 2430, you will overflow your device&#39;s 16-bit integers for many inputs, and of course if you divide by 1024 first, you always underflow.Even if you factor out the greatest common divisor (2) you get 1215/512 with the same problems.  But it turns out that 19/8 approximates this to within 0.08%, or less than one bit.The next better approximation is 83/35, but 83*1023 &gt; 16 bits again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2008/12/knowing-my-weaknesses/comment-page-1/#comment-69</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Sun, 18 Jan 2009 14:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2008/12/06/knowing-my-weaknesses/#comment-69</guid>
		<description>Thanks for your comment Lars. I agree that the C type promotion and casting rules can be a nightmare. I&#039;ve seen some people criticize &#039;unnecessary&#039; casting like you have shown. However, I&#039;m with you on this one, and always use a lot of explicit casting to ensure that I get what I want.As a corollary, I am not a great proponent of using unnecessary parentheses to ensure the order of evaluation of an expression. The order of evaluation rules are much easier to understand (if not always intuitive). Having said that, I find I usually avoid the situation simply by using just one operator per line.</description>
		<content:encoded><![CDATA[<p>Thanks for your comment Lars. I agree that the C type promotion and casting rules can be a nightmare. I&#8217;ve seen some people criticize &#8216;unnecessary&#8217; casting like you have shown. However, I&#8217;m with you on this one, and always use a lot of explicit casting to ensure that I get what I want.As a corollary, I am not a great proponent of using unnecessary parentheses to ensure the order of evaluation of an expression. The order of evaluation rules are much easier to understand (if not always intuitive). Having said that, I find I usually avoid the situation simply by using just one operator per line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://embeddedgurus.com/stack-overflow/2008/12/knowing-my-weaknesses/comment-page-1/#comment-68</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 08 Jan 2009 08:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2008/12/06/knowing-my-weaknesses/#comment-68</guid>
		<description>Dear NigelI think you touch a sore point for many C developers with:y = a * a + c;If y, a and c are all of the same data type, there are no surprises, but lets say:long y, c;short a;In this case, I&#039;m not even sure if:y = a * a;y += c;  is good enough. C might perform the a*a in 16-bit, and only cast to 32-bit afterwards. I&#039;m not sure. So I agree with you point. Know your own (and C&#039;s) weeknesses and code defensively if you are in a danger area. This is what I would do:long y, c;short a;y = (long)a * (long)a + c;That being said, I have not encountered many developers who have not been bitten by C&#039;s implicit casting rules... Another friendly feature from Brian and Dennis :)Best regards and thanks for interesting blog posts, Lars</description>
		<content:encoded><![CDATA[<p>Dear NigelI think you touch a sore point for many C developers with:y = a * a + c;If y, a and c are all of the same data type, there are no surprises, but lets say:long y, c;short a;In this case, I&#8217;m not even sure if:y = a * a;y += c;  is good enough. C might perform the a*a in 16-bit, and only cast to 32-bit afterwards. I&#8217;m not sure. So I agree with you point. Know your own (and C&#8217;s) weeknesses and code defensively if you are in a danger area. This is what I would do:long y, c;short a;y = (long)a * (long)a + c;That being said, I have not encountered many developers who have not been bitten by C&#8217;s implicit casting rules&#8230; Another friendly feature from Brian and Dennis <img src='http://embeddedgurus.com/stack-overflow/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Best regards and thanks for interesting blog posts, Lars</p>
]]></content:encoded>
	</item>
</channel>
</rss>

