<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.3" -->
<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: When crap just doesn&#8217;t add up&#8230;</title>
	<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up</link>
	<description>My thoughts (facts) on everything</description>
	<pubDate>Fri, 21 Nov 2008 13:16:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>

	<item>
		<title>By: Rodrigo</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-115</link>
		<dc:creator>Rodrigo</dc:creator>
		<pubDate>Mon, 20 Oct 2008 16:45:51 +0000</pubDate>
		<guid>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-115</guid>
		<description>Hi, well, i don't know too much about esential programming, reading some internet web sites about this topic, i saw that "it's a world" to know about float and decimal numbers.

But how about to focus on functionality, i mean, a lot of people prefer "microsoft excel" or another ofimatic program and base their lives on it, they don't focus on accuaracy or precission, they just only round a decimal number bigger than "5" the previous decimal, and dislike scientific notation, How to do that?? it is there a class, or function?? i'm a newbie and i feel that this requirement it is not satisfied.</description>
		<content:encoded><![CDATA[<p>Hi, well, i don&#8217;t know too much about esential programming, reading some internet web sites about this topic, i saw that &#8220;it&#8217;s a world&#8221; to know about float and decimal numbers.</p>
<p>But how about to focus on functionality, i mean, a lot of people prefer &#8220;microsoft excel&#8221; or another ofimatic program and base their lives on it, they don&#8217;t focus on accuaracy or precission, they just only round a decimal number bigger than &#8220;5&#8243; the previous decimal, and dislike scientific notation, How to do that?? it is there a class, or function?? i&#8217;m a newbie and i feel that this requirement it is not satisfied.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-113</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Mon, 08 Sep 2008 03:18:12 +0000</pubDate>
		<guid>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-113</guid>
		<description>Very true, Julian. By using the to_d method appended to String by bigdecimal/util, you are no longer converting a Float type, therefor never encounter the accuracy issue. This may be the best way to construct a BigDecimal.</description>
		<content:encoded><![CDATA[<p>Very true, Julian. By using the to_d method appended to String by bigdecimal/util, you are no longer converting a Float type, therefor never encounter the accuracy issue. This may be the best way to construct a BigDecimal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julian Burgess</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-103</link>
		<dc:creator>Julian Burgess</dc:creator>
		<pubDate>Thu, 12 Jun 2008 13:31:33 +0000</pubDate>
		<guid>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-103</guid>
		<description>Unless I'm dumb, isn't string the answer?

x = "1.00000000000000000000000000000000001".to_d
=&#62; #
puts x.to_s("F")
"1.00000000000000000000000000000000001"</description>
		<content:encoded><![CDATA[<p>Unless I&#8217;m dumb, isn&#8217;t string the answer?</p>
<p>x = &#8220;1.00000000000000000000000000000000001&#8243;.to_d<br />
=&gt; #<br />
puts x.to_s(&#8221;F&#8221;)<br />
&#8220;1.00000000000000000000000000000000001&#8243;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fu</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-6</link>
		<dc:creator>Fu</dc:creator>
		<pubDate>Fri, 12 Oct 2007 13:36:58 +0000</pubDate>
		<guid>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-6</guid>
		<description>x = 1.00000000000001.to_d
=&#62; #

puts x.to_s('f')
=&#62; 1.00000000000001

It seems that 14 places is the limit.

x = 1.000000000000001.to_d
=&#62; #
puts x.to_s('f')
=&#62; 1.0

Going to the 15th drops the resolution.</description>
		<content:encoded><![CDATA[<p>x = 1.00000000000001.to_d<br />
=&gt; #</p>
<p>puts x.to_s(&#8217;f')<br />
=&gt; 1.00000000000001</p>
<p>It seems that 14 places is the limit.</p>
<p>x = 1.000000000000001.to_d<br />
=&gt; #<br />
puts x.to_s(&#8217;f')<br />
=&gt; 1.0</p>
<p>Going to the 15th drops the resolution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spacebat</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-5</link>
		<dc:creator>Spacebat</dc:creator>
		<pubDate>Wed, 10 Oct 2007 21:41:19 +0000</pubDate>
		<guid>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-5</guid>
		<description>&lt;code&gt;
x = 1.2000000000000000001.to_d
&lt;/code&gt;

I think what's actually happening here is, Ruby converts the literal number into a float. The float can't represent the 1 at the end so its lost. Then to_d is called and never sees the 1 at the end.

I remember using Borland compilers back in the 90s, and they supported BCD (Binary Coded Decimal). This was the recommended format for financial calculations, but it was slower and slightly wasteful of memory compared to binary floats. Still I'd wager its faster/smaller than BigDecimal (unless the latter is implemented in the former)</description>
		<content:encoded><![CDATA[<p><code><br />
x = 1.2000000000000000001.to_d<br />
</code></p>
<p>I think what&#8217;s actually happening here is, Ruby converts the literal number into a float. The float can&#8217;t represent the 1 at the end so its lost. Then to_d is called and never sees the 1 at the end.</p>
<p>I remember using Borland compilers back in the 90s, and they supported BCD (Binary Coded Decimal). This was the recommended format for financial calculations, but it was slower and slightly wasteful of memory compared to binary floats. Still I&#8217;d wager its faster/smaller than BigDecimal (unless the latter is implemented in the former)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim R. Wilson</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-4</link>
		<dc:creator>Jim R. Wilson</dc:creator>
		<pubDate>Tue, 09 Oct 2007 18:44:39 +0000</pubDate>
		<guid>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-4</guid>
		<description>Nope, nevermind - it really is a problem.  In Ruby, 1.2 - 1.0 - 0.2 gives you -5.55111512312578e-17</description>
		<content:encoded><![CDATA[<p>Nope, nevermind - it really is a problem.  In Ruby, 1.2 - 1.0 - 0.2 gives you -5.55111512312578e-17</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim R. Wilson</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-3</link>
		<dc:creator>Jim R. Wilson</dc:creator>
		<pubDate>Tue, 09 Oct 2007 18:29:26 +0000</pubDate>
		<guid>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-3</guid>
		<description>Is it really due to inaccuracy that 1.2 - 1.0 is not equal to 0.2? I'm tempted to conjecture that Ruby is transparently interpreting the 1.0 as an integer.  Just a thought.  Good post!</description>
		<content:encoded><![CDATA[<p>Is it really due to inaccuracy that 1.2 - 1.0 is not equal to 0.2? I&#8217;m tempted to conjecture that Ruby is transparently interpreting the 1.0 as an integer.  Just a thought.  Good post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-2</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Sat, 29 Sep 2007 16:55:19 +0000</pubDate>
		<guid>http://ramblingsof.justinwinkler.com/when-crap-just-doesnt-add-up#comment-2</guid>
		<description>If you choose to use BigDecimal, there's another thing that you may want to know regarding display. To display a float, you may be familiar with the sprintf and/or format function(s). If you use these functions paired with a BigDecimal, the bad news is that it appears to convert the BigDecimal to Float (probably calls to_f), so you're right back where you started. Instead, to_s on BigDecimal takes a parameter, either 'E' to display in Exponential notation (default), or 'F' to display in Float notation like you're used to seeing.</description>
		<content:encoded><![CDATA[<p>If you choose to use BigDecimal, there&#8217;s another thing that you may want to know regarding display. To display a float, you may be familiar with the sprintf and/or format function(s). If you use these functions paired with a BigDecimal, the bad news is that it appears to convert the BigDecimal to Float (probably calls to_f), so you&#8217;re right back where you started. Instead, to_s on BigDecimal takes a parameter, either &#8216;E&#8217; to display in Exponential notation (default), or &#8216;F&#8217; to display in Float notation like you&#8217;re used to seeing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
