<?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: Incorrectly Rounded Conversions in GCC and GLIBC</title>
	<atom:link href="http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/</link>
	<description>Binary Numbers, Binary Code, and Binary Logic</description>
	<lastBuildDate>Mon, 30 Jan 2012 01:37:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Neil</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4881</link>
		<dc:creator>Neil</dc:creator>
		<pubDate>Sun, 27 Feb 2011 04:32:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4881</guid>
		<description>Heh, just found this article.  Happy to see clang gets it right; I contributed their decimal-&gt;binary code :-)

I submitted the GCC bug 6 years ago; shame there&#039;s little progress.</description>
		<content:encoded><![CDATA[<p>Heh, just found this article.  Happy to see clang gets it right; I contributed their decimal-&gt;binary code <img src='http://www.exploringbinary.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I submitted the GCC bug 6 years ago; shame there&#8217;s little progress.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Regan</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4805</link>
		<dc:creator>Rick Regan</dc:creator>
		<pubDate>Wed, 09 Feb 2011 18:09:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4805</guid>
		<description>@Bob,

Thanks for the report. Your results match the results of an AMD64 user on reddit. What system or you on?</description>
		<content:encoded><![CDATA[<p>@Bob,</p>
<p>Thanks for the report. Your results match the results of an AMD64 user on reddit. What system or you on?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bob nelson</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4803</link>
		<dc:creator>bob nelson</dc:creator>
		<pubDate>Wed, 09 Feb 2011 17:29:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4803</guid>
		<description>gcc 4.4.5:

0.500000000000000166533453693773481063544750213623046875
 Correct = 0x1.0000000000002p-1
 gcc =     0x1.0000000000002p-1
 strtod =  0x1.0000000000001p-1

3.518437208883201171875e13
 Correct = 0x1.0000000000002p+45
 gcc =     0x1.0000000000002p+45
 strtod =  0x1.0000000000001p+45

62.5364939768271845828
 Correct = 0x1.f44abd5aa7ca4p+5
 gcc =     0x1.f44abd5aa7ca4p+5
 strtod =  0x1.f44abd5aa7ca3p+5

8.10109172351e-10
 Correct = 0x1.bd5cbaef0fd0cp-31
 gcc =     0x1.bd5cbaef0fd0cp-31
 strtod =  0x1.bd5cbaef0fd0cp-31

1.50000000000000011102230246251565404236316680908203125
 Correct = 0x1.8p+0
 gcc =     0x1.8p+0
 strtod =  0x1.8p+0

9007199254740991.4999999999999999999999999999999995
 Correct = 0x1.fffffffffffffp+52
 gcc =     0x1.fffffffffffffp+52
 strtod =  0x1.fffffffffffffp+52</description>
		<content:encoded><![CDATA[<p>gcc 4.4.5:</p>
<p>0.500000000000000166533453693773481063544750213623046875<br />
 Correct = 0&#215;1.0000000000002p-1<br />
 gcc =     0&#215;1.0000000000002p-1<br />
 strtod =  0&#215;1.0000000000001p-1</p>
<p>3.518437208883201171875e13<br />
 Correct = 0&#215;1.0000000000002p+45<br />
 gcc =     0&#215;1.0000000000002p+45<br />
 strtod =  0&#215;1.0000000000001p+45</p>
<p>62.5364939768271845828<br />
 Correct = 0&#215;1.f44abd5aa7ca4p+5<br />
 gcc =     0&#215;1.f44abd5aa7ca4p+5<br />
 strtod =  0&#215;1.f44abd5aa7ca3p+5</p>
<p>8.10109172351e-10<br />
 Correct = 0&#215;1.bd5cbaef0fd0cp-31<br />
 gcc =     0&#215;1.bd5cbaef0fd0cp-31<br />
 strtod =  0&#215;1.bd5cbaef0fd0cp-31</p>
<p>1.50000000000000011102230246251565404236316680908203125<br />
 Correct = 0&#215;1.8p+0<br />
 gcc =     0&#215;1.8p+0<br />
 strtod =  0&#215;1.8p+0</p>
<p>9007199254740991.4999999999999999999999999999999995<br />
 Correct = 0&#215;1.fffffffffffffp+52<br />
 gcc =     0&#215;1.fffffffffffffp+52<br />
 strtod =  0&#215;1.fffffffffffffp+52</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michel Hack</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4471</link>
		<dc:creator>Michel Hack</dc:creator>
		<pubDate>Mon, 03 Jan 2011 22:42:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4471</guid>
		<description>My mistake!   754-1985 does not require correct rounding for 22 digits.
I misremembered the 22-digit size of the #3479 example, probably
because I&#039;ve also investigated a number of 17-digit (and even 16-digit)
failures on non-Linux systems.

It is still a glibc bug however, because the comments, and the use of
gmp under the covers, clearly suggest that the intention was to perform 
correct rounding...

Given that glibc uses gmp to convert at least 20 digits, I suspect that it
does not have bugs within the IEEE 754-1985 correct-rounding range.
(For the record, that range is numbers representable as M*10**N with
integers M and N such that &#124;M&#124; &lt; 1e17 and &#124;N&#124; &lt; 28.)

Of course, by now there is IEEE 754-2008 to contend with!   If binary64
is the widest supported FP format, then 20 correctly-rounded digits would
be conforming, provided longer digit strings are first rounded in decimal
to 20 digits, which I suspect is NOT being done.  (That&#039;s understandable,
because that particular requirement was only formulated in late 2006 if
I remember correctly.)

So perhaps I should torture glibc&#039;s strtod() a bit more on post-2008
versions...

Michel.</description>
		<content:encoded><![CDATA[<p>My mistake!   754-1985 does not require correct rounding for 22 digits.<br />
I misremembered the 22-digit size of the #3479 example, probably<br />
because I&#8217;ve also investigated a number of 17-digit (and even 16-digit)<br />
failures on non-Linux systems.</p>
<p>It is still a glibc bug however, because the comments, and the use of<br />
gmp under the covers, clearly suggest that the intention was to perform<br />
correct rounding&#8230;</p>
<p>Given that glibc uses gmp to convert at least 20 digits, I suspect that it<br />
does not have bugs within the IEEE 754-1985 correct-rounding range.<br />
(For the record, that range is numbers representable as M*10**N with<br />
integers M and N such that |M| &lt; 1e17 and |N| &lt; 28.)</p>
<p>Of course, by now there is IEEE 754-2008 to contend with!   If binary64<br />
is the widest supported FP format, then 20 correctly-rounded digits would<br />
be conforming, provided longer digit strings are first rounded in decimal<br />
to 20 digits, which I suspect is NOT being done.  (That&#039;s understandable,<br />
because that particular requirement was only formulated in late 2006 if<br />
I remember correctly.)</p>
<p>So perhaps I should torture glibc&#039;s strtod() a bit more on post-2008<br />
versions&#8230;</p>
<p>Michel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Regan</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4470</link>
		<dc:creator>Rick Regan</dc:creator>
		<pubDate>Mon, 03 Jan 2011 16:38:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4470</guid>
		<description>Michel,

The example in Bugzilla #3479, 3.518437208883201171875E+013, is 22 digits. Is that required to be correctly rounded?</description>
		<content:encoded><![CDATA[<p>Michel,</p>
<p>The example in Bugzilla #3479, 3.518437208883201171875E+013, is 22 digits. Is that required to be correctly rounded?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michel Hack</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4469</link>
		<dc:creator>Michel Hack</dc:creator>
		<pubDate>Sun, 02 Jan 2011 17:13:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4469</guid>
		<description>This reply is a bit late, but I was not following this discussion, and only got
here because of your reply on stds-754 (Re: Conflicts between C standard
and 754-2008).  
 
My bugzilla #3479 violates 754-1985 because it involves fewer than 17
digits and has a middling exponent, within the range where correct rounding
is required.

I&#039;m a bit annoyed that there has been no progress in four years, even though
the fix should be pretty trivial (don&#039;t take the invalid shortcut) -- but I&#039;m not
sufficiently plugged in to the glibc maintenance community to provide my own
bug fix.

Michel</description>
		<content:encoded><![CDATA[<p>This reply is a bit late, but I was not following this discussion, and only got<br />
here because of your reply on stds-754 (Re: Conflicts between C standard<br />
and 754-2008).  </p>
<p>My bugzilla #3479 violates 754-1985 because it involves fewer than 17<br />
digits and has a middling exponent, within the range where correct rounding<br />
is required.</p>
<p>I&#8217;m a bit annoyed that there has been no progress in four years, even though<br />
the fix should be pretty trivial (don&#8217;t take the invalid shortcut) &#8212; but I&#8217;m not<br />
sufficiently plugged in to the glibc maintenance community to provide my own<br />
bug fix.</p>
<p>Michel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Regan</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4354</link>
		<dc:creator>Rick Regan</dc:creator>
		<pubDate>Tue, 08 Jun 2010 13:06:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4354</guid>
		<description>Michel,

My Example 2 is from your bug report (it&#039;s a halfway case that should round up, not down). Can you elaborate on why it &quot;violates 754-1985&quot;? Thanks.

(BTW, it&#039;s 20 digits that the shortcut uses.)</description>
		<content:encoded><![CDATA[<p>Michel,</p>
<p>My Example 2 is from your bug report (it&#8217;s a halfway case that should round up, not down). Can you elaborate on why it &#8220;violates 754-1985&#8243;? Thanks.</p>
<p>(BTW, it&#8217;s 20 digits that the shortcut uses.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michel Hack</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4353</link>
		<dc:creator>Michel Hack</dc:creator>
		<pubDate>Sun, 06 Jun 2010 18:06:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4353</guid>
		<description>(1) C99 and IEEE 754-1985 are somewhat lax on conversion requirements, but IEEE 754-2008 requires correct rounding across the entire exponent range and for at least 20 digits in the case of Binary64.
(2) The bug I reported for glibc several years ago actually violates 754-1985.
(3) The code in glibc is perfectly capable of doing the correct conversion.  The problem is an ill-advised shortcut that claims n digits (30? I don&#039;t remember now) are sufficient, when in fact the threshold is much larger (it depends on the exponent and may be as large as 752 bits).

Michel.</description>
		<content:encoded><![CDATA[<p>(1) C99 and IEEE 754-1985 are somewhat lax on conversion requirements, but IEEE 754-2008 requires correct rounding across the entire exponent range and for at least 20 digits in the case of Binary64.<br />
(2) The bug I reported for glibc several years ago actually violates 754-1985.<br />
(3) The code in glibc is perfectly capable of doing the correct conversion.  The problem is an ill-advised shortcut that claims n digits (30? I don&#8217;t remember now) are sufficient, when in fact the threshold is much larger (it depends on the exponent and may be as large as 752 bits).</p>
<p>Michel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eddie</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4352</link>
		<dc:creator>eddie</dc:creator>
		<pubDate>Sat, 05 Jun 2010 12:14:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4352</guid>
		<description>It&#039;s stock ubuntu 10.4 with the default clang in ubuntu multiverse: clang-2.7-0ubuntu1</description>
		<content:encoded><![CDATA[<p>It&#8217;s stock ubuntu 10.4 with the default clang in ubuntu multiverse: clang-2.7-0ubuntu1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Regan</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4351</link>
		<dc:creator>Rick Regan</dc:creator>
		<pubDate>Sat, 05 Jun 2010 01:59:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4351</guid>
		<description>eddie,

What&#039;s really interesting is that your results are different than the five other sets of results I have (my results above and the 4 sets of results reported on &lt;a title=&quot;See results on Reddit&quot; href=&quot;http://www.reddit.com/r/programming/comments/cb8qv/incorrectly_rounded_conversions_in_gcc_and_glibc/&quot; rel=&quot;nofollow&quot;&gt;reddit&lt;/a&gt;).

Thanks for the data.</description>
		<content:encoded><![CDATA[<p>eddie,</p>
<p>What&#8217;s really interesting is that your results are different than the five other sets of results I have (my results above and the 4 sets of results reported on <a title="See results on Reddit" href="http://www.reddit.com/r/programming/comments/cb8qv/incorrectly_rounded_conversions_in_gcc_and_glibc/" rel="nofollow">reddit</a>).</p>
<p>Thanks for the data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eddie</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4350</link>
		<dc:creator>eddie</dc:creator>
		<pubDate>Sat, 05 Jun 2010 00:57:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4350</guid>
		<description>clang 1.1.27 does the rounding right (eglibc still fails, that was expected), but I&#039;m worried because it doesn&#039;t mimic gcc behaviour when using gcc_conversion, and that will lead to obscure bugs to someone.

Note: The source program was not modified in any way, gcc in the program refers to clang instead.

esanchma@esanchma-virtualized-linux:~/Escritorio$ clang -o examples-clang examples.c 
esanchma@esanchma-virtualized-linux:~/Escritorio$ ./examples-clang 
0.500000000000000166533453693773481063544750213623046875
 Correct = 0x1.0000000000002p-1
 gcc =     0x1.0000000000002p-1
 strtod =  0x1.0000000000001p-1

3.518437208883201171875e13
 Correct = 0x1.0000000000002p+45
 gcc =     0x1.0000000000002p+45
 strtod =  0x1.0000000000001p+45

62.5364939768271845828
 Correct = 0x1.f44abd5aa7ca4p+5
 gcc =     0x1.f44abd5aa7ca4p+5
 strtod =  0x1.f44abd5aa7ca3p+5

8.10109172351e-10
 Correct = 0x1.bd5cbaef0fd0cp-31
 gcc =     0x1.bd5cbaef0fd0cp-31
 strtod =  0x1.bd5cbaef0fd0dp-31

1.50000000000000011102230246251565404236316680908203125
 Correct = 0x1.8p+0
 gcc =     0x1.8p+0
 strtod =  0x1.8p+0

9007199254740991.4999999999999999999999999999999995
 Correct = 0x1.fffffffffffffp+52
 gcc =     0x1.fffffffffffffp+52
 strtod =  0x1.fffffffffffffp+52

esanchma@esanchma-virtualized-linux:~/Escritorio$ clang --version
clang version 1.1 (branches/release_27)
Target: i386-pc-linux-gnu
Thread model: posix</description>
		<content:encoded><![CDATA[<p>clang 1.1.27 does the rounding right (eglibc still fails, that was expected), but I&#8217;m worried because it doesn&#8217;t mimic gcc behaviour when using gcc_conversion, and that will lead to obscure bugs to someone.</p>
<p>Note: The source program was not modified in any way, gcc in the program refers to clang instead.</p>
<p>esanchma@esanchma-virtualized-linux:~/Escritorio$ clang -o examples-clang examples.c<br />
esanchma@esanchma-virtualized-linux:~/Escritorio$ ./examples-clang<br />
0.500000000000000166533453693773481063544750213623046875<br />
 Correct = 0&#215;1.0000000000002p-1<br />
 gcc =     0&#215;1.0000000000002p-1<br />
 strtod =  0&#215;1.0000000000001p-1</p>
<p>3.518437208883201171875e13<br />
 Correct = 0&#215;1.0000000000002p+45<br />
 gcc =     0&#215;1.0000000000002p+45<br />
 strtod =  0&#215;1.0000000000001p+45</p>
<p>62.5364939768271845828<br />
 Correct = 0&#215;1.f44abd5aa7ca4p+5<br />
 gcc =     0&#215;1.f44abd5aa7ca4p+5<br />
 strtod =  0&#215;1.f44abd5aa7ca3p+5</p>
<p>8.10109172351e-10<br />
 Correct = 0&#215;1.bd5cbaef0fd0cp-31<br />
 gcc =     0&#215;1.bd5cbaef0fd0cp-31<br />
 strtod =  0&#215;1.bd5cbaef0fd0dp-31</p>
<p>1.50000000000000011102230246251565404236316680908203125<br />
 Correct = 0&#215;1.8p+0<br />
 gcc =     0&#215;1.8p+0<br />
 strtod =  0&#215;1.8p+0</p>
<p>9007199254740991.4999999999999999999999999999999995<br />
 Correct = 0&#215;1.fffffffffffffp+52<br />
 gcc =     0&#215;1.fffffffffffffp+52<br />
 strtod =  0&#215;1.fffffffffffffp+52</p>
<p>esanchma@esanchma-virtualized-linux:~/Escritorio$ clang &#8211;version<br />
clang version 1.1 (branches/release_27)<br />
Target: i386-pc-linux-gnu<br />
Thread model: posix</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Regan</title>
		<link>http://www.exploringbinary.com/incorrectly-rounded-conversions-in-gcc-and-glibc/comment-page-1/#comment-4349</link>
		<dc:creator>Rick Regan</dc:creator>
		<pubDate>Fri, 04 Jun 2010 21:06:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.exploringbinary.com/?p=285#comment-4349</guid>
		<description>Hi lacos,

  Yes, I am familiar with that C99 text (in fact, it popped up recently on stackoverflow.com). The bottom line is you&#039;re right -- it&#039;s not a bug. I don&#039;t disagree, but that doesn&#039;t mean correct rounding shouldn&#039;t be the goal. After all, there are open &quot;bug&quot; reports in gcc and glibc, which means they think it worthy of consideration. And, there is open source code available that does correct rounding.

BTW, the terms &quot;correct&quot; and &quot;incorrect&quot; might be misleading, but they&#039;re not my terms. A correctly rounded conversion means the closer of two binary floating-point numbers is chosen (I&#039;m assuming the default -- &quot;round to nearest even&quot; -- but other rounding modes can be applied.)

  Thanks for the comment.</description>
		<content:encoded><![CDATA[<p>Hi lacos,</p>
<p>  Yes, I am familiar with that C99 text (in fact, it popped up recently on stackoverflow.com). The bottom line is you&#8217;re right &#8212; it&#8217;s not a bug. I don&#8217;t disagree, but that doesn&#8217;t mean correct rounding shouldn&#8217;t be the goal. After all, there are open &#8220;bug&#8221; reports in gcc and glibc, which means they think it worthy of consideration. And, there is open source code available that does correct rounding.</p>
<p>BTW, the terms &#8220;correct&#8221; and &#8220;incorrect&#8221; might be misleading, but they&#8217;re not my terms. A correctly rounded conversion means the closer of two binary floating-point numbers is chosen (I&#8217;m assuming the default &#8212; &#8220;round to nearest even&#8221; &#8212; but other rounding modes can be applied.)</p>
<p>  Thanks for the comment.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

