<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic High Precision Sum in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/High-Precision-Sum/m-p/983808#M21609</link>
    <description>1.Will you know why the total is different?&lt;BR /&gt;2.Is there a sum function of high precision?&lt;BR /&gt;&lt;BR /&gt;// result&lt;BR /&gt;Sum = 1099999.99999728520000000000&lt;BR /&gt;Sum = 1100000.00003658240000000000&lt;BR /&gt;Sum = 1100000.00000000000000000000&lt;BR /&gt;&lt;BR /&gt;// code&lt;BR /&gt;#include &lt;BR /&gt;#include &lt;BR /&gt;#include "ipp.h"&lt;BR /&gt;&lt;BR /&gt;void main(void)&lt;BR /&gt;{&lt;BR /&gt;int len, i;&lt;BR /&gt;Ipp64f *pSrc, *pWrk;&lt;BR /&gt;IppStatus Status;&lt;BR /&gt;Ipp64f S, R, T;&lt;BR /&gt;&lt;BR /&gt;len = 1000000+1;&lt;BR /&gt;&lt;BR /&gt;pSrc = ippsMalloc_64f(len);&lt;BR /&gt;Status = ippsSet_64f(0.1, pSrc, len);&lt;BR /&gt;*pSrc = 1000000.0;&lt;BR /&gt;&lt;BR /&gt;Status = ippsSum_64f(pSrc, len, &amp;amp;S);&lt;BR /&gt;printf("Sum = %.20f
", S);&lt;BR /&gt;&lt;BR /&gt;S = 0.0;&lt;BR /&gt;pWrk = pSrc;&lt;BR /&gt;for ( i = 0 ; i len ; i++ ) {&lt;BR /&gt;S = S + *pWrk;&lt;BR /&gt;pWrk++;&lt;BR /&gt;}&lt;BR /&gt;printf("Sum = %.20f
", S);&lt;BR /&gt;&lt;BR /&gt;S = 0.0;&lt;BR /&gt;R = 0.0;&lt;BR /&gt;pWrk = pSrc;&lt;BR /&gt;for ( i = 0 ; i len ; i++ ) {&lt;BR /&gt;R = R + *pWrk;&lt;BR /&gt;pWrk++;&lt;BR /&gt;T = S;&lt;BR /&gt;S = S + R;&lt;BR /&gt;T = S - T;&lt;BR /&gt;R = R - T;&lt;BR /&gt;}&lt;BR /&gt;printf("Sum = %.20f
", S);&lt;BR /&gt;&lt;BR /&gt;ippsFree(pSrc);&lt;BR /&gt;&lt;BR /&gt;printf("push any key
"); getch();&lt;BR /&gt;}</description>
    <pubDate>Thu, 21 Jul 2005 14:55:13 GMT</pubDate>
    <dc:creator>seiji-torigoe</dc:creator>
    <dc:date>2005-07-21T14:55:13Z</dc:date>
    <item>
      <title>High Precision Sum</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/High-Precision-Sum/m-p/983808#M21609</link>
      <description>1.Will you know why the total is different?&lt;BR /&gt;2.Is there a sum function of high precision?&lt;BR /&gt;&lt;BR /&gt;// result&lt;BR /&gt;Sum = 1099999.99999728520000000000&lt;BR /&gt;Sum = 1100000.00003658240000000000&lt;BR /&gt;Sum = 1100000.00000000000000000000&lt;BR /&gt;&lt;BR /&gt;// code&lt;BR /&gt;#include &lt;BR /&gt;#include &lt;BR /&gt;#include "ipp.h"&lt;BR /&gt;&lt;BR /&gt;void main(void)&lt;BR /&gt;{&lt;BR /&gt;int len, i;&lt;BR /&gt;Ipp64f *pSrc, *pWrk;&lt;BR /&gt;IppStatus Status;&lt;BR /&gt;Ipp64f S, R, T;&lt;BR /&gt;&lt;BR /&gt;len = 1000000+1;&lt;BR /&gt;&lt;BR /&gt;pSrc = ippsMalloc_64f(len);&lt;BR /&gt;Status = ippsSet_64f(0.1, pSrc, len);&lt;BR /&gt;*pSrc = 1000000.0;&lt;BR /&gt;&lt;BR /&gt;Status = ippsSum_64f(pSrc, len, &amp;amp;S);&lt;BR /&gt;printf("Sum = %.20f
", S);&lt;BR /&gt;&lt;BR /&gt;S = 0.0;&lt;BR /&gt;pWrk = pSrc;&lt;BR /&gt;for ( i = 0 ; i len ; i++ ) {&lt;BR /&gt;S = S + *pWrk;&lt;BR /&gt;pWrk++;&lt;BR /&gt;}&lt;BR /&gt;printf("Sum = %.20f
", S);&lt;BR /&gt;&lt;BR /&gt;S = 0.0;&lt;BR /&gt;R = 0.0;&lt;BR /&gt;pWrk = pSrc;&lt;BR /&gt;for ( i = 0 ; i len ; i++ ) {&lt;BR /&gt;R = R + *pWrk;&lt;BR /&gt;pWrk++;&lt;BR /&gt;T = S;&lt;BR /&gt;S = S + R;&lt;BR /&gt;T = S - T;&lt;BR /&gt;R = R - T;&lt;BR /&gt;}&lt;BR /&gt;printf("Sum = %.20f
", S);&lt;BR /&gt;&lt;BR /&gt;ippsFree(pSrc);&lt;BR /&gt;&lt;BR /&gt;printf("push any key
"); getch();&lt;BR /&gt;}</description>
      <pubDate>Thu, 21 Jul 2005 14:55:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/High-Precision-Sum/m-p/983808#M21609</guid>
      <dc:creator>seiji-torigoe</dc:creator>
      <dc:date>2005-07-21T14:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: High Precision Sum</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/High-Precision-Sum/m-p/983809#M21610</link>
      <description>&lt;DIV&gt;Hi,&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;there is answer from our expert:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000080" size="2"&gt;
&lt;P&gt;So 0.3E-10 accuracy is not enough? &lt;/P&gt;
&lt;P&gt;Let us do several simple calculations:&lt;/P&gt;
&lt;P&gt;You use for sum the rounded number (0.1 cant be presented as combination of powers of 2, in hex it is 0x3FB999999999999A, that means that the last bit has been already rounded). Therefore for every add instruction we lose for the last bit 0.5 of accuracy (2.2204460492503131e-016  it is the weight of the last bit (I mean 64f data type which has 53bit mantissa), so for 0.5 bit we have ~1E-16). For your length = ~1E6 the accuracy loss is 1E6 * 1E-16 = ~1E-10, which is completely correspond to the result you have obtained.&lt;/P&gt;
&lt;P&gt;If you need more precise sum you should use BigNumberArithmetic library with synthetic data types. &lt;/P&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Regards,&lt;/DIV&gt;
&lt;DIV&gt; Vladimir&lt;/DIV&gt;</description>
      <pubDate>Wed, 27 Jul 2005 23:07:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/High-Precision-Sum/m-p/983809#M21610</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2005-07-27T23:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: High Precision Sum</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/High-Precision-Sum/m-p/983810#M21611</link>
      <description>Thanks.&lt;BR /&gt;It is all right.&lt;BR /&gt;I was expecting the high accuracy of my code end.&lt;BR /&gt;It is regrettable.</description>
      <pubDate>Thu, 28 Jul 2005 07:48:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/High-Precision-Sum/m-p/983810#M21611</guid>
      <dc:creator>seiji-torigoe</dc:creator>
      <dc:date>2005-07-28T07:48:02Z</dc:date>
    </item>
  </channel>
</rss>

