<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Spot the Bug</title>
	<link>http://cafe.elharo.com/programming/spot-the-bug/</link>
	<description>Longer than a blog; shorter than a book</description>
	<pubDate>Sun, 20 Jul 2008 17:18:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: extremoyun</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-248756</link>
		<dc:creator>extremoyun</dc:creator>
		<pubDate>Thu, 17 Jul 2008 08:27:42 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-248756</guid>
		<description>.Use BigDecimal and NumberFormat class to format the output. Thank</description>
		<content:encoded><![CDATA[<p>.Use BigDecimal and NumberFormat class to format the output. Thank</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rixoyun</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-248498</link>
		<dc:creator>rixoyun</dc:creator>
		<pubDate>Wed, 16 Jul 2008 11:50:25 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-248498</guid>
		<description>Zack: If MzScheme indeed prints that, it is violating the Scheme standard, which requires that all inexact numbers be printed using the nearest exact numeral. Python is doing the right thing.</description>
		<content:encoded><![CDATA[<p>Zack: If MzScheme indeed prints that, it is violating the Scheme standard, which requires that all inexact numbers be printed using the nearest exact numeral. Python is doing the right thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kral oyun</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-248497</link>
		<dc:creator>kral oyun</dc:creator>
		<pubDate>Wed, 16 Jul 2008 11:48:18 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-248497</guid>
		<description>are expressed as fractions in binary formats , so using double as data type for these would have caused the problem.
no problem</description>
		<content:encoded><![CDATA[<p>are expressed as fractions in binary formats , so using double as data type for these would have caused the problem.<br />
no problem</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cenk oyun</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-248477</link>
		<dc:creator>cenk oyun</dc:creator>
		<pubDate>Wed, 16 Jul 2008 10:25:50 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-248477</guid>
		<description>Problem description:
In Java floating points are expressed as fractions in binary formats , so using double as data type for these would have caused the problem.
no problem</description>
		<content:encoded><![CDATA[<p>Problem description:<br />
In Java floating points are expressed as fractions in binary formats , so using double as data type for these would have caused the problem.<br />
no problem</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Madden</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-219591</link>
		<dc:creator>David Madden</dc:creator>
		<pubDate>Tue, 22 Apr 2008 21:42:53 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-219591</guid>
		<description>Take a look at this post: http://jug.org.ua/wiki/display/JavaAlmanac/The+Need+for+BigDecimal+-+Core+Java+Technology+Tech+Tips</description>
		<content:encoded><![CDATA[<p>Take a look at this post: <a href="http://jug.org.ua/wiki/display/JavaAlmanac/The+Need+for+BigDecimal+-+Core+Java+Technology+Tech+Tips" rel="nofollow">http://jug.org.ua/wiki/display/JavaAlmanac/The+Need+for+BigDecimal+-+Core+Java+Technology+Tech+Tips</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Cowan</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-202903</link>
		<dc:creator>John Cowan</dc:creator>
		<pubDate>Mon, 10 Mar 2008 03:58:13 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-202903</guid>
		<description>Alan Little:  Cobol does indeed allow you to say DECIMAL POINT IS COMMA, and you can insert punctuation editing characters wherever you like -- you aren't restricted to putting one every three places.   In any case, Indian numbers aren't every four places:  it's one thousand = 1,000; one lakh (10^5) = 1,00,000, and one crore (10^7) = 1,00,00,000.  It's Archimede's &lt;i&gt;Sand Reckoner&lt;/i&gt; that worked in multiples of one myriad (10^4).

Zack:  If MzScheme indeed prints that, it is violating the Scheme standard, which requires that all inexact numbers be printed using the nearest exact numeral.  Python is doing the right thing.</description>
		<content:encoded><![CDATA[<p>Alan Little:  Cobol does indeed allow you to say DECIMAL POINT IS COMMA, and you can insert punctuation editing characters wherever you like &#8212; you aren&#8217;t restricted to putting one every three places.   In any case, Indian numbers aren&#8217;t every four places:  it&#8217;s one thousand = 1,000; one lakh (10^5) = 1,00,000, and one crore (10^7) = 1,00,00,000.  It&#8217;s Archimede&#8217;s <i>Sand Reckoner</i> that worked in multiples of one myriad (10^4).</p>
<p>Zack:  If MzScheme indeed prints that, it is violating the Scheme standard, which requires that all inexact numbers be printed using the nearest exact numeral.  Python is doing the right thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MHMD</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-200684</link>
		<dc:creator>MHMD</dc:creator>
		<pubDate>Wed, 05 Mar 2008 07:38:26 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-200684</guid>
		<description>Hi,

 My perspective about analyzing the above code in java would be,

 BUG:
  Total:9.879999999999999
Expected:
  Total:9.88
Problem description:
  In Java floating points are expressed as fractions in binary formats , so using double as data type for these would have caused the problem.

Solution:
Quick Fix:

  1.Use float instead of double that would give the exact answer need for this case.
  2.In case if the double is needed in anyways then use NumberFormat class to format the output

Original Solution:
  1.Use BigDecimal and NumberFormat class to format the output.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p> My perspective about analyzing the above code in java would be,</p>
<p> BUG:<br />
  Total:9.879999999999999<br />
Expected:<br />
  Total:9.88<br />
Problem description:<br />
  In Java floating points are expressed as fractions in binary formats , so using double as data type for these would have caused the problem.</p>
<p>Solution:<br />
Quick Fix:</p>
<p>  1.Use float instead of double that would give the exact answer need for this case.<br />
  2.In case if the double is needed in anyways then use NumberFormat class to format the output</p>
<p>Original Solution:<br />
  1.Use BigDecimal and NumberFormat class to format the output.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Farrell</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-189931</link>
		<dc:creator>Pat Farrell</dc:creator>
		<pubDate>Thu, 14 Feb 2008 03:38:13 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-189931</guid>
		<description>There may be more, but the criminal sin is using floating point for money. 

Any language used by folks who might use money to do anything, needs a Money or Currency intrinsic type so that rookie programmers don't shoot themselves in the feet using floating point.

I'm not asking for Euro to Pounds Sterling to Dollars, just a Money datatype.</description>
		<content:encoded><![CDATA[<p>There may be more, but the criminal sin is using floating point for money. </p>
<p>Any language used by folks who might use money to do anything, needs a Money or Currency intrinsic type so that rookie programmers don&#8217;t shoot themselves in the feet using floating point.</p>
<p>I&#8217;m not asking for Euro to Pounds Sterling to Dollars, just a Money datatype.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: duncan</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-188934</link>
		<dc:creator>duncan</dc:creator>
		<pubDate>Mon, 11 Feb 2008 23:32:39 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-188934</guid>
		<description>The upstream commenters who point out that some code will have to deal with amounts less than one cent are of course correct, but if you know you will only be dealing with US currency and that you will not have to deal with fractions of a penny, handling currency in pennies makes a lot of sense as a defensive measure. It's not always appropriate, but where it is I don't see a problem with it.</description>
		<content:encoded><![CDATA[<p>The upstream commenters who point out that some code will have to deal with amounts less than one cent are of course correct, but if you know you will only be dealing with US currency and that you will not have to deal with fractions of a penny, handling currency in pennies makes a lot of sense as a defensive measure. It&#8217;s not always appropriate, but where it is I don&#8217;t see a problem with it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aadis</title>
		<link>http://cafe.elharo.com/programming/spot-the-bug/#comment-188472</link>
		<dc:creator>aadis</dc:creator>
		<pubDate>Mon, 11 Feb 2008 03:56:52 +0000</pubDate>
		<guid>http://cafe.elharo.com/programming/spot-the-bug/#comment-188472</guid>
		<description>And the shipping URL page should have the order number string pre-appended (like "shipping.jsp?order=#####"). Another less semantic load :)</description>
		<content:encoded><![CDATA[<p>And the shipping URL page should have the order number string pre-appended (like &#8220;shipping.jsp?order=#####&#8221;). Another less semantic load <img src='http://cafe.elharo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
