<?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: Anatomy of a floating point number</title>
	<atom:link href="http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/</link>
	<description>John D. Cook</description>
	<lastBuildDate>Wed, 19 Jun 2013 18:25:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Javier</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14148</link>
		<dc:creator>Javier</dc:creator>
		<pubDate>Sat, 14 Jul 2012 16:31:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14148</guid>
		<description><![CDATA[Hi Jack,

I am trying to explain why 1.f = (2-2^(-52))

1.f = 2⁰+2^(-1) + 2^(-2) + ... + 2^(-52)
so,
2^(52) (1.f) = 2^(52) + 2^(51) + ... + 2⁰ = 2^(53) - 1 (this is the key)

And finally,

1.f= (2^(53) - 1) / 2^(52) = 2 - 2^(-52)

Best regards,
Javier]]></description>
		<content:encoded><![CDATA[<p>Hi Jack,</p>
<p>I am trying to explain why 1.f = (2-2^(-52))</p>
<p>1.f = 2⁰+2^(-1) + 2^(-2) + &#8230; + 2^(-52)<br />
so,<br />
2^(52) (1.f) = 2^(52) + 2^(51) + &#8230; + 2⁰ = 2^(53) &#8211; 1 (this is the key)</p>
<p>And finally,</p>
<p>1.f= (2^(53) &#8211; 1) / 2^(52) = 2 &#8211; 2^(-52)</p>
<p>Best regards,<br />
Javier</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barnaby</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14147</link>
		<dc:creator>Barnaby</dc:creator>
		<pubDate>Tue, 21 Feb 2012 17:56:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14147</guid>
		<description><![CDATA[Be great to add a diagram showing the bit structure of a float. The first time I learned about them there was a diagram and I found it incredibly clear in one glance. :-)]]></description>
		<content:encoded><![CDATA[<p>Be great to add a diagram showing the bit structure of a float. The first time I learned about them there was a diagram and I found it incredibly clear in one glance. <img src='http://www.johndcook.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14146</link>
		<dc:creator>Jack</dc:creator>
		<pubDate>Mon, 02 Jan 2012 15:16:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14146</guid>
		<description><![CDATA[Thanks for the more detailed article on floating point; they&#039;re hard to find. I was wondering, my math is a little weak. How do you get the expression 2^1023(2 - 2^-52) from 1.f * 2^1023, where f is a string of 52 1&#039;s. I assume the 2^1023 remains untouched, so the question then is how do you get (2 - 2^-52) from 1.f? I tried finding a common denominator, so (2^52 + 2^51 + ... 2^0) / 2^52, but didn&#039;t seem to get me anywhere.
Thanks.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the more detailed article on floating point; they&#8217;re hard to find. I was wondering, my math is a little weak. How do you get the expression 2^1023(2 &#8211; 2^-52) from 1.f * 2^1023, where f is a string of 52 1&#8242;s. I assume the 2^1023 remains untouched, so the question then is how do you get (2 &#8211; 2^-52) from 1.f? I tried finding a common denominator, so (2^52 + 2^51 + &#8230; 2^0) / 2^52, but didn&#8217;t seem to get me anywhere.<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: What I&#8217;ve been reading this week: Low level links, Legos for adults and a free AI course by Peter Norvig.</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14145</link>
		<dc:creator>What I&#8217;ve been reading this week: Low level links, Legos for adults and a free AI course by Peter Norvig.</dc:creator>
		<pubDate>Sun, 14 Aug 2011 01:39:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14145</guid>
		<description><![CDATA[[...] floating point arithmetic.  On John D. Cook&#8217;s blog,  Numbers are a Leaky Abstraction and  Anatomy of a Floating Point Number are two interesting posts that deal with the various gotchas about working with floating point [...] ]]></description>
		<content:encoded><![CDATA[<p>[...] floating point arithmetic.  On John D. Cook&#8217;s blog,  Numbers are a Leaky Abstraction and  Anatomy of a Floating Point Number are two interesting posts that deal with the various gotchas about working with floating point [...] </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antonio</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14144</link>
		<dc:creator>Antonio</dc:creator>
		<pubDate>Thu, 07 Jul 2011 16:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14144</guid>
		<description><![CDATA[IEEE should hurry up with that floating point interval arithmetic standard http://en.wikipedia.org/wiki/Interval_arithmetic#IEEE_Interval_Standard_.E2.80.93_P1788]]></description>
		<content:encoded><![CDATA[<p>IEEE should hurry up with that floating point interval arithmetic standard <a href="http://en.wikipedia.org/wiki/Interval_arithmetic#IEEE_Interval_Standard_.E2.80.93_P1788" rel="nofollow">http://en.wikipedia.org/wiki/Interval_arithmetic#IEEE_Interval_Standard_.E2.80.93_P1788</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nemo</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14143</link>
		<dc:creator>Nemo</dc:creator>
		<pubDate>Wed, 13 Oct 2010 20:33:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14143</guid>
		<description><![CDATA[In C++, the standard way to deal with these constants is via the parameterized &lt;a href=&quot;http://www.cplusplus.com/reference/std/limits/numeric_limits/&quot; rel=&quot;nofollow&quot;&gt;numeric_limits&lt;/a&gt; class:

#include &lt;limits&gt;

double x = std::numeric_limits&lt;double&gt;::max();
double y = std::numeric_limits&lt;double&gt;::epsilon();
double nan = std::numeric_limits&lt;double&gt;::quiet_nan();
[etc.]

This has the advantage of working for float, double, long double, and whatever is in vogue tomorrow...  It also works for the integer types (well, not NaN, but you know what I mean).  It also works for typedefs where you neither know nor care what the underlying type is:

typedef long double real_t;

real_t x = std::numeric_limits&lt;real_t&gt;::max();

The &lt;limits&gt; header is part of the C++98 standard, so this also has the advantage of being perfectly portable across 21st-century compilers.]]></description>
		<content:encoded><![CDATA[<p>In C++, the standard way to deal with these constants is via the parameterized <a href="http://www.cplusplus.com/reference/std/limits/numeric_limits/" rel="nofollow">numeric_limits</a> class:</p>
<p>#include &lt;limits&gt;</p>
<p>double x = std::numeric_limits&lt;double&gt;::max();<br />
double y = std::numeric_limits&lt;double&gt;::epsilon();<br />
double nan = std::numeric_limits&lt;double&gt;::quiet_nan();<br />
[etc.]</p>
<p>This has the advantage of working for float, double, long double, and whatever is in vogue tomorrow&#8230;  It also works for the integer types (well, not NaN, but you know what I mean).  It also works for typedefs where you neither know nor care what the underlying type is:</p>
<p>typedef long double real_t;</p>
<p>real_t x = std::numeric_limits&lt;real_t&gt;::max();</p>
<p>The &lt;limits&gt; header is part of the C++98 standard, so this also has the advantage of being perfectly portable across 21st-century compilers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manjunath</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14142</link>
		<dc:creator>Manjunath</dc:creator>
		<pubDate>Tue, 23 Jun 2009 08:10:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14142</guid>
		<description><![CDATA[of course i did similar thing for test this function by generating NaN and in VC6 its failed.  Then i&#039;ve tried with quiet NaN for verifying it.]]></description>
		<content:encoded><![CDATA[<p>of course i did similar thing for test this function by generating NaN and in VC6 its failed.  Then i&#8217;ve tried with quiet NaN for verifying it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14141</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 23 Jun 2009 07:44:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14141</guid>
		<description><![CDATA[In my test code, I made my own NaNs manually rather than using &lt;code&gt;quiet_NaN()&lt;/code&gt;. For example, I&#039;d have code like 

&lt;code&gt;x = -1.0; z = sqrt(x); assert(!IsNumber(z));&lt;/code&gt; 

or 

&lt;code&gt;x = 1.0; y = 0.0; x /= y; z = y*x; assert(!IsNumber(z));&lt;/code&gt;

I also have some more elaborate code to generate a quiet NaN. Maybe VC6 has a bug in &lt;code&gt;quiet_NaN&lt;/code&gt;? I wouldn&#039;t think so, but that seems more plausible than a violation of IEEE arithmetic.]]></description>
		<content:encoded><![CDATA[<p>In my test code, I made my own NaNs manually rather than using <code>quiet_NaN()</code>. For example, I&#8217;d have code like </p>
<p><code>x = -1.0; z = sqrt(x); assert(!IsNumber(z));</code> </p>
<p>or </p>
<p><code>x = 1.0; y = 0.0; x /= y; z = y*x; assert(!IsNumber(z));</code></p>
<p>I also have some more elaborate code to generate a quiet NaN. Maybe VC6 has a bug in <code>quiet_NaN</code>? I wouldn&#8217;t think so, but that seems more plausible than a violation of IEEE arithmetic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manjunath</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14140</link>
		<dc:creator>Manjunath</dc:creator>
		<pubDate>Tue, 23 Jun 2009 07:32:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14140</guid>
		<description><![CDATA[John, In gcc its working fine, but VC6 its not working as expected.  
Here is my x,
x = numeric_limits::quiet_NaN();]]></description>
		<content:encoded><![CDATA[<p>John, In gcc its working fine, but VC6 its not working as expected.<br />
Here is my x,<br />
x = numeric_limits::quiet_NaN();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14139</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 23 Jun 2009 07:23:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14139</guid>
		<description><![CDATA[Manjunath, I&#039;m surprised to hear that. I&#039;ve tested that function on several versions of Visual C++, though I can&#039;t recall whether I tested VC6. I&#039;ve tested it on several versions of gcc as well.]]></description>
		<content:encoded><![CDATA[<p>Manjunath, I&#8217;m surprised to hear that. I&#8217;ve tested that function on several versions of Visual C++, though I can&#8217;t recall whether I tested VC6. I&#8217;ve tested it on several versions of gcc as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manjunath</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14138</link>
		<dc:creator>Manjunath</dc:creator>
		<pubDate>Tue, 23 Jun 2009 05:54:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14138</guid>
		<description><![CDATA[bool IsNumber(double x) 
    {
        // This looks like it should always be true, 
        // but it&#039;s false if x is a NaN.
        return (x == x); 
    }
mentioned in &quot;IEEE floating-point exceptions in C++&quot;
This is not working at least in VC++ 6.0 compiler]]></description>
		<content:encoded><![CDATA[<p>bool IsNumber(double x)<br />
    {<br />
        // This looks like it should always be true,<br />
        // but it&#8217;s false if x is a NaN.<br />
        return (x == x);<br />
    }<br />
mentioned in &#8220;IEEE floating-point exceptions in C++&#8221;<br />
This is not working at least in VC++ 6.0 compiler</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Math Teachers at Play #5 &#171; Let&#8217;s Play Math!</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14137</link>
		<dc:creator>Math Teachers at Play #5 &#171; Let&#8217;s Play Math!</dc:creator>
		<pubDate>Fri, 17 Apr 2009 12:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14137</guid>
		<description><![CDATA[[...] John Cook presents Floating point numbers are a leaky abstraction. This is the first of two blog posts about how computer arithmetic works and what problems to look out for. (Part 2 here.) [...] ]]></description>
		<content:encoded><![CDATA[<p>[...] John Cook presents Floating point numbers are a leaky abstraction. This is the first of two blog posts about how computer arithmetic works and what problems to look out for. (Part 2 here.) [...] </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14136</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 07 Apr 2009 15:39:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14136</guid>
		<description><![CDATA[Karl, thanks for pointing out the mistake. I updated the post after reading your correction.]]></description>
		<content:encoded><![CDATA[<p>Karl, thanks for pointing out the mistake. I updated the post after reading your correction.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Ove Hufthammer</title>
		<link>http://www.johndcook.com/blog/2009/04/06/anatomy-of-a-floating-point-number/comment-page-1/#comment-14135</link>
		<dc:creator>Karl Ove Hufthammer</dc:creator>
		<pubDate>Tue, 07 Apr 2009 15:21:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1956#comment-14135</guid>
		<description><![CDATA[Thanks for the nice summary of floating point numbers. BTW, I think you made a small mistake in the third paragraph: 2043 should be 2047.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the nice summary of floating point numbers. BTW, I think you made a small mistake in the third paragraph: 2043 should be 2047.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
