<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.silverlight.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Silverlight Tip of the Day #40: 1.05 != 1.05 - Peril with Floating Point Comparisons.</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx</link><description>The other day I found a bug in one of my Silverlight applications that was doing floating point comparisons. In my animation of an image I was increasing the ScaleTransform .ScaleX by “0.05” from “0.0” to “2.0 and checking to see when my ScaleTransform</description><dc:language>en</dc:language><generator>CommunityServer 2007 (Build: 20416.853)</generator><item><title>presentão de Ano Novo: dúzias de dicas e tutoriais de Silverlight ;)</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#155393</link><pubDate>Sat, 03 Jan 2009 11:25:46 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:155393</guid><dc:creator>o UAU nosso de cada dia</dc:creator><description>&lt;p&gt;essa lista eu copiei desse blog b&amp;#225;rbaro (acompanhe por RSS voc&amp;#234; tamb&amp;#233;m): uma lista de dicas super &amp;#250;teis&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=155393" width="1" height="1"&gt;</description></item><item><title>Silverlight Tips of the Day - Summary Outline</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#155151</link><pubDate>Fri, 02 Jan 2009 22:57:06 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:155151</guid><dc:creator>Silverlight Tips of the Day - Blog by Mike Snow</dc:creator><description>&lt;p&gt;The purpose of this post is to create an outline summary all the blogs from my Silverlight tips of the&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=155151" width="1" height="1"&gt;</description></item><item><title>Silverlight Tips of the Day - Summary Outline</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#155150</link><pubDate>Fri, 02 Jan 2009 22:57:06 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:155150</guid><dc:creator>Silverlight Tips of the Day - Blog by Mike Snow</dc:creator><description>&lt;p&gt;The purpose of this post is to create an outline summary all the blogs from my Silverlight tips of the&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=155150" width="1" height="1"&gt;</description></item><item><title>Silverlight Tips of the Day – Week 7</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#97069</link><pubDate>Thu, 25 Sep 2008 17:56:16 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:97069</guid><dc:creator>Visual Web Developer Team Blog</dc:creator><description>&lt;p&gt;Silverlight Tip of the Day #46 Title: Font Support in Silverlight Silverlight Tip of the Day #45: Title:&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=97069" width="1" height="1"&gt;</description></item><item><title>Silverlight Cream for September 15, 2008 -- #368</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#91762</link><pubDate>Mon, 15 Sep 2008 19:20:35 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:91762</guid><dc:creator>Community Blogs</dc:creator><description>&lt;p&gt;Martin Mihaylov on the DataGrid, Bart Czernicki on Game Concepts, James Bacon on an update to Mashooo&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=91762" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #40: 1.05 != 1.05 - Peril with Floating Point Comparisons.</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#91146</link><pubDate>Sun, 14 Sep 2008 02:39:08 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:91146</guid><dc:creator>michaeldrotar</dc:creator><description>&lt;p&gt;Good tip. Floating point comparisons are often a source of frustration.&lt;/p&gt;
&lt;p&gt;The examples aren't quite equivalent though. The first one is saying to stop when scaleX is 2.0 and the second is saying to stop when scaleX is greater than 2.0&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=91146" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #40: 1.05 != 1.05 - Peril with Floating Point Comparisons.</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#91074</link><pubDate>Sat, 13 Sep 2008 16:20:44 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:91074</guid><dc:creator>mike.snow</dc:creator><description>&lt;p&gt;ZGor - Actually I agree, i'll change it to your solution.&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=91074" width="1" height="1"&gt;</description></item><item><title>Dew Drop - September 13, 2008 | Alvin Ashcraft's Morning Dew</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#91051</link><pubDate>Sat, 13 Sep 2008 13:53:20 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:91051</guid><dc:creator>Dew Drop - September 13, 2008 | Alvin Ashcraft's Morning Dew</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Dew Drop - September 13, 2008 | Alvin Ashcraft's Morning Dew&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=91051" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #40: 1.05 != 1.05 - Peril with Floating Point Comparisons.</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#91027</link><pubDate>Sat, 13 Sep 2008 12:18:58 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:91027</guid><dc:creator>zgor</dc:creator><description>&lt;p&gt;I don't feel comfortable with your alternative solution. It is of course an alternative but I don't want to multiply 0.05 by 40 in mind to get 2.0, my actual loop ending number.&lt;/p&gt;
&lt;p&gt;My way would be the following:&lt;/p&gt;
&lt;p&gt;scale.ScaleX = 0.0;&lt;/p&gt;
&lt;p&gt;while (scale.ScaleX &amp;lt;= 2.0)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;scale.ScaleX += 0.05;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;// Do stuff here...&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;[ you see, we don't have a &amp;quot;40&amp;quot; in the code :) ]&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=91027" width="1" height="1"&gt;</description></item><item><title>re: Silverlight Tip of the Day #40: 1.05 != 1.05 - Peril with Floating Point Comparisons.</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#90813</link><pubDate>Fri, 12 Sep 2008 20:17:09 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:90813</guid><dc:creator>Skyrunner</dc:creator><description>&lt;p&gt;It's like in any other application.&lt;/p&gt;
&lt;p&gt;Floating calcul has always been bad.&lt;/p&gt;
&lt;p&gt;float f1 = 0.1f * 0.1f;&lt;/p&gt;
&lt;p&gt;float f2 = 0.01f;&lt;/p&gt;
&lt;p&gt;if (f1.Equals(f2)) Console.WriteLine(&amp;quot;f1 = f2&amp;quot;);&lt;/p&gt;
&lt;p&gt;Should use float.Epsilon for compare them.&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=90813" width="1" height="1"&gt;</description></item><item><title>Silverlight Tip of the Day #40: 1.05 != 1.05 - Peril with Floating Point Comparisons.</title><link>http://blogs.silverlight.net/blogs/msnow/archive/2008/09/12/silverlight-tip-of-the-day-40-1-05-1-05.aspx#90719</link><pubDate>Fri, 12 Sep 2008 17:17:37 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:90719</guid><dc:creator>Blogs</dc:creator><description>&lt;p&gt;The other day I found a bug in one of my Silverlight applications that was doing floating point comparisons&lt;/p&gt;
&lt;img src="http://blogs.silverlight.net/aggbug.aspx?PostID=90719" width="1" height="1"&gt;</description></item></channel></rss>