Note that there are some explanatory texts on larger screens.

plurals
  1. POgcc rounding difference between versions
    primarykey
    data
    text
    <p>I'm looking into <a href="https://github.com/imageworks/OpenColorIO/issues/168">why a test case is failing</a></p> <p>The problematic test can be reduced to doing <code>(4.0/9.0) ** (1.0/2.6)</code>, rounding this to 6 digits and checking against a known value (as a string):</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;math.h&gt; int main(){ printf("%.06f\n", powf(4.0/9.0, (1.0/2.6))); } </code></pre> <p>If I compile and run this in gcc 4.1.2 on Linux, I get:</p> <pre><code>0.732057 </code></pre> <p>Python agrees, as does <a href="http://www.wolframalpha.com/input/?i=%284.0%2F9.0%29%2a%2a%281%2F2.6%29">Wolfram|Alpha</a>:</p> <pre><code>$ python2.7 -c 'print "%.06f" % (4.0/9.0)**(1/2.6)' 0.732057 </code></pre> <p>However I get the following result on gcc 4.4.0 on Linux, and 4.2.1 on OS X:</p> <pre><code>0.732058 </code></pre> <p>A <code>double</code> acts identically (although I didn't test this extensively)</p> <p>I'm not sure how to narrow this down any further.. Is this a gcc regression? A change in rounding algorithm? Me doing something silly?</p> <p><strong>Edit:</strong> Printing the result to 12 digits, the digit at the 7th place is 4 vs 5, which explains the rounding difference, but not the value difference:</p> <p>gcc 4.1.2:</p> <pre><code>0.732057452202 </code></pre> <p>gcc 4.4.0:</p> <pre><code>0.732057511806 </code></pre> <p>Here's the <code>gcc -S</code> output from both versions: <a href="https://gist.github.com/1588729">https://gist.github.com/1588729</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload