<?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: WTFJS</title>
	<atom:link href="http://ajaxian.com/archives/wtfjs/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/wtfjs</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: Pies</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-279736</link>
		<dc:creator>Pies</dc:creator>
		<pubDate>Sat, 06 Mar 2010 01:51:10 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-279736</guid>
		<description>I don&#039;t think this is very useful, but it certainly pays to remember, that all high-level languages are full of abstractions, and it can be very confusing if you use them without the full understanding of exactly what and how is abstracted away.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think this is very useful, but it certainly pays to remember, that all high-level languages are full of abstractions, and it can be very confusing if you use them without the full understanding of exactly what and how is abstracted away.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: paulypaul</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278905</link>
		<dc:creator>paulypaul</dc:creator>
		<pubDate>Thu, 18 Feb 2010 10:20:19 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278905</guid>
		<description>parseInt(&#039;08&#039;) - assumes you in octal

parseInt(&#039;08&#039;, 10) -  changes to base 10</description>
		<content:encoded><![CDATA[<p>parseInt(&#8217;08&#8242;) &#8211; assumes you in octal</p>
<p>parseInt(&#8217;08&#8242;, 10) &#8211;  changes to base 10</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278903</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Wed, 17 Feb 2010 16:21:57 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278903</guid>
		<description>wspace, &lt;blockquote&gt;I don’t think you understand what I’m telling you ...&lt;/blockquote&gt; Maybe because what followed never appeared anywhere in your previous comment? Anyhow, you&#039;re right: 0.1 + 0.2 == 0.3  returns false in those languages. I&#039;m surprised, given the different results of 0.1 + 0.2 in those languages versus ECMAScript and Java.

&lt;blockquote&gt; This is not some JavaScript weirdness, it’s a well-known consequence of the impossibility to express either of these numbers exactly as a floating point number.&lt;/blockquote&gt; I&#039;m well aware. It can, however, be solved.

As far as your continued suggestion to read more, I&#039;m familiar with the issues involved on a general level, and never claimed it was &quot;JavaScript weirdness&quot;. I was mislead in practice by the inconsistencies of results in those languages versus in ECMAScript.

&lt;blockquote&gt; All in all, none of these WTFJS examples are really surprising for anyone who’s been working with the language for a while. Personally, I think giving null the type “object” was not a wise design decision, but I can live with that.&lt;/blockquote&gt; Agreed, agreed.

&lt;blockquote&gt; If you want some serious WTFs, look at IE’s treatment of host objects.&lt;/blockquote&gt; But here I think we&#039;re looking at WTFDOM, not WTFJS. I don&#039;t know the ins and outs of this bug, but it seems to me that the internal DOM is lying to the JScript engine.

Anyway, thanks for correcting my error. I hope you&#039;ll understand why I was mislead, and accept that my misunderstanding of specific behavior doesn&#039;t betray a misunderstanding of how floating point numbers work generally.</description>
		<content:encoded><![CDATA[<p>wspace,<br />
<blockquote>I don’t think you understand what I’m telling you &#8230;</p></blockquote>
<p> Maybe because what followed never appeared anywhere in your previous comment? Anyhow, you&#8217;re right: 0.1 + 0.2 == 0.3  returns false in those languages. I&#8217;m surprised, given the different results of 0.1 + 0.2 in those languages versus ECMAScript and Java.</p>
<blockquote><p> This is not some JavaScript weirdness, it’s a well-known consequence of the impossibility to express either of these numbers exactly as a floating point number.</p></blockquote>
<p> I&#8217;m well aware. It can, however, be solved.</p>
<p>As far as your continued suggestion to read more, I&#8217;m familiar with the issues involved on a general level, and never claimed it was &#8220;JavaScript weirdness&#8221;. I was mislead in practice by the inconsistencies of results in those languages versus in ECMAScript.</p>
<blockquote><p> All in all, none of these WTFJS examples are really surprising for anyone who’s been working with the language for a while. Personally, I think giving null the type “object” was not a wise design decision, but I can live with that.</p></blockquote>
<p> Agreed, agreed.</p>
<blockquote><p> If you want some serious WTFs, look at IE’s treatment of host objects.</p></blockquote>
<p> But here I think we&#8217;re looking at WTFDOM, not WTFJS. I don&#8217;t know the ins and outs of this bug, but it seems to me that the internal DOM is lying to the JScript engine.</p>
<p>Anyway, thanks for correcting my error. I hope you&#8217;ll understand why I was mislead, and accept that my misunderstanding of specific behavior doesn&#8217;t betray a misunderstanding of how floating point numbers work generally.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sourceRoot</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278901</link>
		<dc:creator>sourceRoot</dc:creator>
		<pubDate>Wed, 17 Feb 2010 15:10:59 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278901</guid>
		<description>Very interesting!!! from a Physiological / Philosophical perspective. I&#039;ve been developing for about 15 years now, started in Pascal then C then Java ... thats when I got it.. There are endless overflows,NPEs,false positives positive negatives and vulnerabilities caused by FP math in general. I have the scars to prove it.

The thing that I &quot;got&quot; when I started in Java (and this was 8 years ago) was.. the vast majority of young developers, have little knowledge of these ever present inaccuracies. There are in fact, many of them. It&#039;s not necessarily a bad thing though. Young developers expect there tools to work. I cant blame them at all, it frees up a few time slices for other processes. Thats why VMs like Java and .Net are so popular (disclaimer I have never used nor do I know much about .Net). I started getting serious about a year ago, and I&#039;m somewhat dismayed at the state of the language myself. 

P.S.
bit shifting in JS.. wtf is that good for? :)</description>
		<content:encoded><![CDATA[<p>Very interesting!!! from a Physiological / Philosophical perspective. I&#8217;ve been developing for about 15 years now, started in Pascal then C then Java &#8230; thats when I got it.. There are endless overflows,NPEs,false positives positive negatives and vulnerabilities caused by FP math in general. I have the scars to prove it.</p>
<p>The thing that I &#8220;got&#8221; when I started in Java (and this was 8 years ago) was.. the vast majority of young developers, have little knowledge of these ever present inaccuracies. There are in fact, many of them. It&#8217;s not necessarily a bad thing though. Young developers expect there tools to work. I cant blame them at all, it frees up a few time slices for other processes. Thats why VMs like Java and .Net are so popular (disclaimer I have never used nor do I know much about .Net). I started getting serious about a year ago, and I&#8217;m somewhat dismayed at the state of the language myself. </p>
<p>P.S.<br />
bit shifting in JS.. wtf is that good for? :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wspace</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278894</link>
		<dc:creator>wspace</dc:creator>
		<pubDate>Tue, 16 Feb 2010 15:35:34 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278894</guid>
		<description>@eyelidlessness, I don&#039;t think you understand what I&#039;m telling you: the expression &quot;0.1 + 0.2 == 0.3&quot; is *false* in Perl, Ruby, PHP, and Python (your counter examples). This is not some JavaScript weirdness, it&#039;s a well-known consequence of the impossibility to express either of these numbers exactly as a floating point number. You can call it ridiculous if you want, but if you want to understand what&#039;s going on, why these numbers cannot be exact, and why it&#039;s a bad idea to test for equality where the results of float operations are concerned, I suggest you read up on this topic.
.
All in all, none of these WTFJS examples are really surprising for anyone who&#039;s been working with the language for a while. Personally, I think giving null the type &quot;object&quot; was not a wise design decision, but I can live with that.
If you want some serious WTFs, look at IE&#039;s treatment of host objects.
window == document; // true, but
document == window; // false
Ugh. And this is only the tip of the iceberg...</description>
		<content:encoded><![CDATA[<p>@eyelidlessness, I don&#8217;t think you understand what I&#8217;m telling you: the expression &#8220;0.1 + 0.2 == 0.3&#8243; is *false* in Perl, Ruby, PHP, and Python (your counter examples). This is not some JavaScript weirdness, it&#8217;s a well-known consequence of the impossibility to express either of these numbers exactly as a floating point number. You can call it ridiculous if you want, but if you want to understand what&#8217;s going on, why these numbers cannot be exact, and why it&#8217;s a bad idea to test for equality where the results of float operations are concerned, I suggest you read up on this topic.<br />
.<br />
All in all, none of these WTFJS examples are really surprising for anyone who&#8217;s been working with the language for a while. Personally, I think giving null the type &#8220;object&#8221; was not a wise design decision, but I can live with that.<br />
If you want some serious WTFs, look at IE&#8217;s treatment of host objects.<br />
window == document; // true, but<br />
document == window; // false<br />
Ugh. And this is only the tip of the iceberg&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cyrusomar</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278892</link>
		<dc:creator>cyrusomar</dc:creator>
		<pubDate>Tue, 16 Feb 2010 12:35:43 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278892</guid>
		<description>Using equality with floating point has always been asking for trouble, whether it is with NaN or the result of a floating point expression. This is true in any language which uses standard floats or doubles, and has been for many years now. Javascript follows the standard (NaNs should not be compared for equality, this is part of the IEEE spec).</description>
		<content:encoded><![CDATA[<p>Using equality with floating point has always been asking for trouble, whether it is with NaN or the result of a floating point expression. This is true in any language which uses standard floats or doubles, and has been for many years now. Javascript follows the standard (NaNs should not be compared for equality, this is part of the IEEE spec).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hansschmucker</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278891</link>
		<dc:creator>hansschmucker</dc:creator>
		<pubDate>Tue, 16 Feb 2010 12:06:02 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278891</guid>
		<description>Hmm? Do Perl, PHP, Python or ruby use more than a double?</description>
		<content:encoded><![CDATA[<p>Hmm? Do Perl, PHP, Python or ruby use more than a double?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278888</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Tue, 16 Feb 2010 06:39:18 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278888</guid>
		<description>Not going to jump back in the argument, but I&#039;ll just fix this :
&quot;Precision of floating point numbers in Perl, PHP, Python and Ruby is greater than that in ECMAScript and Java.&quot;
Java do implement float and BigDecimal as well.</description>
		<content:encoded><![CDATA[<p>Not going to jump back in the argument, but I&#8217;ll just fix this :<br />
&#8220;Precision of floating point numbers in Perl, PHP, Python and Ruby is greater than that in ECMAScript and Java.&#8221;<br />
Java do implement float and BigDecimal as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278885</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Tue, 16 Feb 2010 03:08:06 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278885</guid>
		<description>wspace, &lt;blockquote&gt; Perl, PHP, Python, and Ruby all show the same rounding errors, but not necessarily for simple operations like 0.1 + 0.2&lt;/blockquote&gt; I don&#039;t think that&#039;s an accurate statement. The question isn&#039;t simplicity or complexity of operations, but degree of precision. Precision of floating point numbers in Perl, PHP, Python and Ruby is greater than that in ECMAScript and Java. I didn&#039;t attempt to claim that numbers in those language have infinite precision, I hope that&#039;s clear now.

&lt;blockquote&gt;JavaScript doesn’t have a “decimal” type. There was an effort by IBM to get it into ECMAScript 5, but it was voted down by the committee.&lt;/blockquote&gt; Yes, this is true. This is because IBM was steadfast in the particular standard they insisted on using. Both sides were in error, in my opinion.

I&#039;m not sure if this point was intended as a rebuttal or correction, so if it was I don&#039;t know how to address it.

&lt;blockquote&gt;bc is a different case; it’s a calculator, and has its own oddities. Try calling it (without the -l option), and it will tell you that 3/2 makes 1.&lt;/blockquote&gt; This isn&#039;t a rounding error, it&#039;s a rounding default that is not what one might intuit. It simply rounds to an integer (down for 0-5) by default.

&lt;blockquote&gt;I don’t have AppleScript available for testing.&lt;/blockquote&gt; AppleScript doesn&#039;t support the operations in question, so it is untestable. It seems the precision is equal to that of Perl, PHP, Python and Ruby, as 1234567.1229999999 and 1234567.123 both output 1.234567123E+6.

&lt;blockquote&gt;If you need more information about this, search for “IEEE-754?.&lt;/blockquote&gt; Again, I&#039;m not sure if this is meant as a rebuttal or correction of something, so I&#039;m not sure how to address it. Nothing I&#039;ve said here is inaccurate and I think I&#039;ve adequately addressed the question of precision as it differs from ECMAScript to certain of other languages.</description>
		<content:encoded><![CDATA[<p>wspace,<br />
<blockquote> Perl, PHP, Python, and Ruby all show the same rounding errors, but not necessarily for simple operations like 0.1 + 0.2</p></blockquote>
<p> I don&#8217;t think that&#8217;s an accurate statement. The question isn&#8217;t simplicity or complexity of operations, but degree of precision. Precision of floating point numbers in Perl, PHP, Python and Ruby is greater than that in ECMAScript and Java. I didn&#8217;t attempt to claim that numbers in those language have infinite precision, I hope that&#8217;s clear now.</p>
<blockquote><p>JavaScript doesn’t have a “decimal” type. There was an effort by IBM to get it into ECMAScript 5, but it was voted down by the committee.</p></blockquote>
<p> Yes, this is true. This is because IBM was steadfast in the particular standard they insisted on using. Both sides were in error, in my opinion.</p>
<p>I&#8217;m not sure if this point was intended as a rebuttal or correction, so if it was I don&#8217;t know how to address it.</p>
<blockquote><p>bc is a different case; it’s a calculator, and has its own oddities. Try calling it (without the -l option), and it will tell you that 3/2 makes 1.</p></blockquote>
<p> This isn&#8217;t a rounding error, it&#8217;s a rounding default that is not what one might intuit. It simply rounds to an integer (down for 0-5) by default.</p>
<blockquote><p>I don’t have AppleScript available for testing.</p></blockquote>
<p> AppleScript doesn&#8217;t support the operations in question, so it is untestable. It seems the precision is equal to that of Perl, PHP, Python and Ruby, as 1234567.1229999999 and 1234567.123 both output 1.234567123E+6.</p>
<blockquote><p>If you need more information about this, search for “IEEE-754?.</p></blockquote>
<p> Again, I&#8217;m not sure if this is meant as a rebuttal or correction of something, so I&#8217;m not sure how to address it. Nothing I&#8217;ve said here is inaccurate and I think I&#8217;ve adequately addressed the question of precision as it differs from ECMAScript to certain of other languages.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wspace</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278884</link>
		<dc:creator>wspace</dc:creator>
		<pubDate>Tue, 16 Feb 2010 02:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278884</guid>
		<description>@eyelidless: Perl, PHP, Python, and Ruby all show the same rounding errors, but not necessarily for simple operations like 0.1 + 0.2:

$ perl -e &#039;printf(&quot;%.10f\n&quot;, 1234567.123)&#039;
1234567.1229999999
$ php -r &#039;printf(&quot;%.10f\n&quot;, 1234567.123);&#039;
1234567.1229999999
$ ruby -e &#039;printf(&quot;%.10f\n&quot;, 1234567.123);&#039;
1234567.1229999999
$ python -c &#039;print &quot;%.10f&quot; % 1234567.123&#039;
1234567.1229999999

JavaScript doesn&#039;t have a &quot;decimal&quot; type. There was an effort by IBM to get it into ECMAScript 5, but it was voted down by the committee.

bc is a different case; it&#039;s a calculator, and has its own oddities. Try calling it (without the -l option), and it will tell you that 3/2 makes 1. I don&#039;t have AppleScript available for testing.

If you need more information about this, search for &quot;IEEE-754&quot;.</description>
		<content:encoded><![CDATA[<p>@eyelidless: Perl, PHP, Python, and Ruby all show the same rounding errors, but not necessarily for simple operations like 0.1 + 0.2:</p>
<p>$ perl -e &#8216;printf(&#8220;%.10f\n&#8221;, 1234567.123)&#8217;<br />
1234567.1229999999<br />
$ php -r &#8216;printf(&#8220;%.10f\n&#8221;, 1234567.123);&#8217;<br />
1234567.1229999999<br />
$ ruby -e &#8216;printf(&#8220;%.10f\n&#8221;, 1234567.123);&#8217;<br />
1234567.1229999999<br />
$ python -c &#8216;print &#8220;%.10f&#8221; % 1234567.123&#8242;<br />
1234567.1229999999</p>
<p>JavaScript doesn&#8217;t have a &#8220;decimal&#8221; type. There was an effort by IBM to get it into ECMAScript 5, but it was voted down by the committee.</p>
<p>bc is a different case; it&#8217;s a calculator, and has its own oddities. Try calling it (without the -l option), and it will tell you that 3/2 makes 1. I don&#8217;t have AppleScript available for testing.</p>
<p>If you need more information about this, search for &#8220;IEEE-754&#8243;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278883</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Mon, 15 Feb 2010 22:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278883</guid>
		<description>ywg,

You said that any programmer in any language should expect &lt;code&gt;0.1 + 0.2 === 0.3 // false&lt;/code&gt;.

You are incorrect. This isn&#039;t a matter of opinion, I provided half a dozen examples where a programmer would not and should not expect that. The differences, then, between double and float, are moot. Look again at your first comment. It had nothing to do with double or float, just whether or not &lt;code&gt;0.1 + 0.2 === 0.3&lt;/code&gt;. All the &quot;WTF&quot; was pointing out was that ECMAScript&#039;s floating-point precision is not sufficient for that mathematical equation to behave as expected from a mathematical standpoint. This is true in other languages (Java being the example you provided), but not true in other languages as well (perl, php, python, ruby, AppleScript and bc being the examples I provided). It&#039;s &lt;strong&gt;without a doubt&lt;/strong&gt; language-specific, because some (but not all) languages have this problem.</description>
		<content:encoded><![CDATA[<p>ywg,</p>
<p>You said that any programmer in any language should expect <code>0.1 + 0.2 === 0.3 // false</code>.</p>
<p>You are incorrect. This isn&#8217;t a matter of opinion, I provided half a dozen examples where a programmer would not and should not expect that. The differences, then, between double and float, are moot. Look again at your first comment. It had nothing to do with double or float, just whether or not <code>0.1 + 0.2 === 0.3</code>. All the &#8220;WTF&#8221; was pointing out was that ECMAScript&#8217;s floating-point precision is not sufficient for that mathematical equation to behave as expected from a mathematical standpoint. This is true in other languages (Java being the example you provided), but not true in other languages as well (perl, php, python, ruby, AppleScript and bc being the examples I provided). It&#8217;s <strong>without a doubt</strong> language-specific, because some (but not all) languages have this problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278880</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Mon, 15 Feb 2010 20:56:23 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278880</guid>
		<description>I do not agree :
1 - You just demonstrated that you are confusing Float and Double.
2 - &quot;It then doesn’t follow that this is something any programmer should expect&quot;
.
IMHO not knowing about the differences between a Float and a Double is a real fault for any experienced developper.
Don&#039;t take it personnally, this is not against you. But I just consider this to be some fundamental knowledge.</description>
		<content:encoded><![CDATA[<p>I do not agree :<br />
1 &#8211; You just demonstrated that you are confusing Float and Double.<br />
2 &#8211; &#8220;It then doesn’t follow that this is something any programmer should expect&#8221;<br />
.<br />
IMHO not knowing about the differences between a Float and a Double is a real fault for any experienced developper.<br />
Don&#8217;t take it personnally, this is not against you. But I just consider this to be some fundamental knowledge.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278879</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Mon, 15 Feb 2010 20:35:07 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278879</guid>
		<description>ywg,

Let me clarify what I am and am not saying. First, what I&#039;m &lt;strong&gt;not&lt;/strong&gt; saying:

1. ECMAScript is unique in floating point imprecision.
2. Imprecise floating point operations are unavailable in other languages.

What I &lt;strong&gt;am&lt;/strong&gt; saying:

1. 0.1 + 0.2 != 0.3 is not (as you claimed) the case in &quot;any programming language&quot;, and I demonstrated that.
2. It then doesn&#039;t follow that this is something any programmer should expect, negating the importance of pointing out the oddity in ECMAScript for those who expect 0.1 + 0.2 == 0.3.

Therefore, 0.1 + 0.2 != 0.3 does not belong to &quot;WTFANYPROGRAMMINGLANGUAGE&quot;, as in quite a lot of programming languages that is not the case.</description>
		<content:encoded><![CDATA[<p>ywg,</p>
<p>Let me clarify what I am and am not saying. First, what I&#8217;m <strong>not</strong> saying:</p>
<p>1. ECMAScript is unique in floating point imprecision.<br />
2. Imprecise floating point operations are unavailable in other languages.</p>
<p>What I <strong>am</strong> saying:</p>
<p>1. 0.1 + 0.2 != 0.3 is not (as you claimed) the case in &#8220;any programming language&#8221;, and I demonstrated that.<br />
2. It then doesn&#8217;t follow that this is something any programmer should expect, negating the importance of pointing out the oddity in ECMAScript for those who expect 0.1 + 0.2 == 0.3.</p>
<p>Therefore, 0.1 + 0.2 != 0.3 does not belong to &#8220;WTFANYPROGRAMMINGLANGUAGE&#8221;, as in quite a lot of programming languages that is not the case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278878</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Mon, 15 Feb 2010 19:39:24 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278878</guid>
		<description>Java :
double a = 0.1, b = 0.2, c = 0.3;

System.out.println(a+b==c); // false
System.out.println(a+b); // 0.30000000000000004</description>
		<content:encoded><![CDATA[<p>Java :<br />
double a = 0.1, b = 0.2, c = 0.3;</p>
<p>System.out.println(a+b==c); // false<br />
System.out.println(a+b); // 0.30000000000000004</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278877</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Mon, 15 Feb 2010 19:31:22 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278877</guid>
		<description>@eyelidlessness
This is not ridiculous, and this has nothing to do with ECMAscript, try to search by yourself if you don&#039;t believe me.
.
Java comes with double, C/C++ comes with double, Python comes with double (in fact, I believe this was the first language that implemented it).
The only reason your above examples work it&#039;s because they use Float by default.
.
JS did not wrap up it&#039;s own buggy floating point abstraction, it&#039;s something perfectly standard and very common.</description>
		<content:encoded><![CDATA[<p>@eyelidlessness<br />
This is not ridiculous, and this has nothing to do with ECMAscript, try to search by yourself if you don&#8217;t believe me.<br />
.<br />
Java comes with double, C/C++ comes with double, Python comes with double (in fact, I believe this was the first language that implemented it).<br />
The only reason your above examples work it&#8217;s because they use Float by default.<br />
.<br />
JS did not wrap up it&#8217;s own buggy floating point abstraction, it&#8217;s something perfectly standard and very common.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278876</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Mon, 15 Feb 2010 19:20:17 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278876</guid>
		<description>ywg, I&#039;m sorry but that&#039;s ridiculous.

perl -e &#039;print .1 + .2 . &quot;\n&quot;;&#039;
0.3

php -r &#039;print .1 + .2 . &quot;\n&quot;;&#039;
0.3

python -
&gt;&gt;&gt; print .1 + .2
0.3

ruby -e &#039;print 0.1 + 0.2; print &quot;\n&quot;;&#039;
0.3

AppleScript:
.1 + .2
0.3

bc
.1 + .2
.3

I don&#039;t really have time to go any further, but the only other language I could find where .1 + .2 != .3 is ActionScript, another ECMA variant.</description>
		<content:encoded><![CDATA[<p>ywg, I&#8217;m sorry but that&#8217;s ridiculous.</p>
<p>perl -e &#8216;print .1 + .2 . &#8220;\n&#8221;;&#8217;<br />
0.3</p>
<p>php -r &#8216;print .1 + .2 . &#8220;\n&#8221;;&#8217;<br />
0.3</p>
<p>python -<br />
&gt;&gt;&gt; print .1 + .2<br />
0.3</p>
<p>ruby -e &#8216;print 0.1 + 0.2; print &#8220;\n&#8221;;&#8217;<br />
0.3</p>
<p>AppleScript:<br />
.1 + .2<br />
0.3</p>
<p>bc<br />
.1 + .2<br />
.3</p>
<p>I don&#8217;t really have time to go any further, but the only other language I could find where .1 + .2 != .3 is ActionScript, another ECMA variant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tracker1</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278875</link>
		<dc:creator>tracker1</dc:creator>
		<pubDate>Mon, 15 Feb 2010 18:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278875</guid>
		<description>Honestly, I find it more funny that NaN != NaN.  One of the annoyances is when you want to determin if a reference is valid (in terms of core types).  IE, not null, not undefined, not an empty string, and not an invalid date or number.  Just posted about that on my blog this morning actually.

(typeof obj == &#039;number&#039; and isNaN(obj)) will let you know if the value is NaN, which would be nicer to simply be able to compare == NaN or === NaN like you can for an empty string, but not Undefined either.  The other thing that&#039;s nice and painful at the same time, is that null, &#039;&#039;, false and 0 all have equality, so you need to test for explicit equality if 0 is valid but say false isn&#039;t etc.</description>
		<content:encoded><![CDATA[<p>Honestly, I find it more funny that NaN != NaN.  One of the annoyances is when you want to determin if a reference is valid (in terms of core types).  IE, not null, not undefined, not an empty string, and not an invalid date or number.  Just posted about that on my blog this morning actually.</p>
<p>(typeof obj == &#8216;number&#8217; and isNaN(obj)) will let you know if the value is NaN, which would be nicer to simply be able to compare == NaN or === NaN like you can for an empty string, but not Undefined either.  The other thing that&#8217;s nice and painful at the same time, is that null, &#8221;, false and 0 all have equality, so you need to test for explicit equality if 0 is valid but say false isn&#8217;t etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278874</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Mon, 15 Feb 2010 17:31:08 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278874</guid>
		<description>@eyelidlessness
Especially for floating numbers. This is just a side effect of Double, which is the most common floating point abstraction, almost every programming language ships with an implementation of Double.</description>
		<content:encoded><![CDATA[<p>@eyelidlessness<br />
Especially for floating numbers. This is just a side effect of Double, which is the most common floating point abstraction, almost every programming language ships with an implementation of Double.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278872</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Mon, 15 Feb 2010 17:10:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278872</guid>
		<description>To build on what hansschmucker said...

Anyone who would expect &lt;code&gt;typeof null&lt;/code&gt; returning &quot;object&quot; to mean that &lt;code&gt;null === Object&lt;/code&gt; needs to take a step back and thing about it. This is true for &lt;strong&gt;everything that returns &quot;object&quot;&lt;/strong&gt;, null is no exception.

And to ywg,

&quot;Theses do not belong to WTFJS, but to WTFANYPROGRAMINGLANGUAGE&quot;

Even the nightmare that is ECMA&#039;s float standard choice, really? I don&#039;t use any other language that treats 0.1 that way. I&#039;m sure plenty do, but it&#039;s definitely not a given and it can definitely lead to unexpected errors.</description>
		<content:encoded><![CDATA[<p>To build on what hansschmucker said&#8230;</p>
<p>Anyone who would expect <code>typeof null</code> returning &#8220;object&#8221; to mean that <code>null === Object</code> needs to take a step back and thing about it. This is true for <strong>everything that returns &#8220;object&#8221;</strong>, null is no exception.</p>
<p>And to ywg,</p>
<p>&#8220;Theses do not belong to WTFJS, but to WTFANYPROGRAMINGLANGUAGE&#8221;</p>
<p>Even the nightmare that is ECMA&#8217;s float standard choice, really? I don&#8217;t use any other language that treats 0.1 that way. I&#8217;m sure plenty do, but it&#8217;s definitely not a given and it can definitely lead to unexpected errors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: henrah</title>
		<link>http://ajaxian.com/archives/wtfjs/comment-page-1#comment-278870</link>
		<dc:creator>henrah</dc:creator>
		<pubDate>Mon, 15 Feb 2010 14:56:33 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=8603#comment-278870</guid>
		<description>@sstchur:
&gt;&gt; &quot;if it’s Not a Number, why is its type a number?&quot;

it is a numeric representation of something that is not a number. The value expressed by NaN has the &lt;i&gt;type&lt;/i&gt; &quot;number&quot; because it is produced by numeric expressions (such as 1/0), and all numeric expressions have to provide numeric values.

In some ways it is the equivalent of null, in the sense that null is the representation of an object reference that does not exist, while NaN is the representation of a numeric value that does not exist.</description>
		<content:encoded><![CDATA[<p>@sstchur:<br />
&gt;&gt; &#8220;if it’s Not a Number, why is its type a number?&#8221;</p>
<p>it is a numeric representation of something that is not a number. The value expressed by NaN has the <i>type</i> &#8220;number&#8221; because it is produced by numeric expressions (such as 1/0), and all numeric expressions have to provide numeric values.</p>
<p>In some ways it is the equivalent of null, in the sense that null is the representation of an object reference that does not exist, while NaN is the representation of a numeric value that does not exist.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

