<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>porges &#187; annoyances</title>
	<atom:link href="http://porg.es/blog/tag/annoyances/feed" rel="self" type="application/rss+xml" />
	<link>http://porg.es/blog</link>
	<description></description>
	<lastBuildDate>Thu, 12 Jan 2012 23:45:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sometimes it&#8217;s all too much&#8230;</title>
		<link>http://porg.es/blog/sometimes-its-all-too-much</link>
		<comments>http://porg.es/blog/sometimes-its-all-too-much#comments</comments>
		<pubDate>Mon, 22 Jun 2009 13:19:54 +0000</pubDate>
		<dc:creator>Porges</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[annoyances]]></category>
		<category><![CDATA[builtins]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[floating-point]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[processor]]></category>

		<guid isPermaLink="false">http://porg.es/blog/?p=365</guid>
		<description><![CDATA[Argh #include &#60;stdio.h&#62; #include &#60;math.h&#62; #include &#60;fenv.h&#62; &#160; int main &#40;&#41; &#123; // don't set rounding here double ten0 = sin&#40;pow&#40;10.0,22&#41;&#41;; &#160; fesetround&#40;FE_DOWNWARD&#41;; double ten1 = sin&#40;pow&#40;10.0,22&#41;&#41;; &#160; fesetround&#40;FE_UPWARD&#41;; double ten2 = sin&#40;pow&#40;10.0,22&#41;&#41;; &#160; fesetround&#40;FE_TONEAREST&#41;; double ten3 = sin&#40;pow&#40;10.0,22&#41;&#41;; &#160; fesetround&#40;FE_TOWARDZERO&#41;; double ten4 = sin&#40;pow&#40;10.0,22&#41;&#41;; &#160; printf&#40; &#34;Default: %f\n&#34; &#34;Downward: %f\n&#34; &#34;Upward: %f\n&#34; &#34;ToNearest: %f\n&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Argh <img src="http://porg.es/blog/wp-content/plugins/wp-smiley-switcher/noktahhitam/icon_sad.gif" alt="" /></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;math.h&gt;</span>
<span style="color: #339933;">#include &lt;fenv.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// don't set rounding here</span>
	<span style="color: #993333;">double</span> ten0 <span style="color: #339933;">=</span> sin<span style="color: #009900;">&#40;</span>pow<span style="color: #009900;">&#40;</span><span style="color:#800080;">10.0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">22</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	fesetround<span style="color: #009900;">&#40;</span>FE_DOWNWARD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">double</span> ten1 <span style="color: #339933;">=</span> sin<span style="color: #009900;">&#40;</span>pow<span style="color: #009900;">&#40;</span><span style="color:#800080;">10.0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">22</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	fesetround<span style="color: #009900;">&#40;</span>FE_UPWARD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">double</span> ten2 <span style="color: #339933;">=</span> sin<span style="color: #009900;">&#40;</span>pow<span style="color: #009900;">&#40;</span><span style="color:#800080;">10.0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">22</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	fesetround<span style="color: #009900;">&#40;</span>FE_TONEAREST<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">double</span> ten3 <span style="color: #339933;">=</span> sin<span style="color: #009900;">&#40;</span>pow<span style="color: #009900;">&#40;</span><span style="color:#800080;">10.0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">22</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	fesetround<span style="color: #009900;">&#40;</span>FE_TOWARDZERO<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">double</span> ten4 <span style="color: #339933;">=</span> sin<span style="color: #009900;">&#40;</span>pow<span style="color: #009900;">&#40;</span><span style="color:#800080;">10.0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">22</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span>
		<span style="color: #ff0000;">&quot;Default:    %f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #ff0000;">&quot;Downward:   %f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #ff0000;">&quot;Upward:     %f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #ff0000;">&quot;ToNearest:  %f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #ff0000;">&quot;TowardZero: %f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
		ten0<span style="color: #339933;">,</span> ten1<span style="color: #339933;">,</span>
		ten2<span style="color: #339933;">,</span> ten3<span style="color: #339933;">,</span> ten4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">gcc</span> test.c <span style="color: #660033;">-lm</span> <span style="color: #660033;">-fno-builtin</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> .<span style="color: #000000; font-weight: bold;">/</span>a.out
Default:    <span style="color: #000000;">0.462613</span>
Downward:   <span style="color: #000000;">0.986580</span>
Upward:     <span style="color: #000000;">0.462613</span>
ToNearest:  <span style="color: #000000;">0.462613</span>
TowardZero: <span style="color: #000000;">0.986580</span>
~$ <span style="color: #c20cb9; font-weight: bold;">gcc</span> test.c <span style="color: #660033;">-lm</span>  <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> .<span style="color: #000000; font-weight: bold;">/</span>a.out
Default:    -<span style="color: #000000;">0.852201</span>
Downward:   -<span style="color: #000000;">0.852201</span>
Upward:     -<span style="color: #000000;">0.852201</span>
ToNearest:  -<span style="color: #000000;">0.852201</span>
TowardZero: -<span style="color: #000000;">0.852201</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://porg.es/blog/sometimes-its-all-too-much/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

