<?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 Re: fast test for double &amp;lt; 0.0 and round it to 0.0 in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/fast-test-for-double-lt-0-0-and-round-it-to-0-0/m-p/915976#M12594</link>
    <description>In such a situation, you may get better results from something similar to&lt;BR /&gt;time = t * dt;&lt;BR /&gt;Possibly faster might be to keep a double copy of t to use in this calculation.&lt;BR /&gt;&lt;BR /&gt;Setting abrupt underflow (e.g. by setting /Qftz in your compilation) might avoid accidental generation of such small non-zero numbers.&lt;BR /&gt;&lt;BR /&gt;When you use SSE2 or SSE3, your&lt;BR /&gt;if (time&amp;lt;0.0) time=0.0; &lt;BR /&gt;should compile to fast code (maxsd instruction, no branching).&lt;BR /&gt;</description>
    <pubDate>Sun, 24 Feb 2008 22:30:21 GMT</pubDate>
    <dc:creator>TimP</dc:creator>
    <dc:date>2008-02-24T22:30:21Z</dc:date>
    <item>
      <title>fast test for double &lt; 0.0 and round it to 0.0</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/fast-test-for-double-lt-0-0-and-round-it-to-0-0/m-p/915975#M12593</link>
      <description>&lt;P&gt;Hi, (Intel 10.1, VS2005, min target build Core2 microarch SSE3)&lt;/P&gt;
&lt;P&gt;I have a very tight loop decrementing a double that looks like:&lt;/P&gt;
&lt;P&gt;double time, dt;&lt;BR /&gt;for (int t=N-1; t&amp;gt;=0; t--)&lt;BR /&gt;...&lt;BR /&gt; time -= dt;&lt;/P&gt;
&lt;P&gt;with dt variable, depending on t, but such that at the end of the loop (t==0), time shouldbe "exactly" 0.0.. Due naturally to floating calculations, time sometimes becomes negative-1e-170 or so...&lt;/P&gt;
&lt;P&gt;1) I believe there is some flag to "round down" to 0 if a double is small "enough"...&lt;/P&gt;
&lt;P&gt;2) Otherwise, i could do a test to see if time is negative....&lt;BR /&gt; time -= dt;&lt;BR /&gt; if (time&amp;lt;0.0) time=0.0;&lt;BR /&gt;Is this fast enough? Or is there some other function from mathimf.h to do it faster? ( i mean that gets assembled to some more appropriate instruction )....&lt;/P&gt;
&lt;P&gt;regards,&lt;/P&gt;</description>
      <pubDate>Sun, 24 Feb 2008 21:29:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/fast-test-for-double-lt-0-0-and-round-it-to-0-0/m-p/915975#M12593</guid>
      <dc:creator>finjulhich</dc:creator>
      <dc:date>2008-02-24T21:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: fast test for double &lt; 0.0 and round it to 0.0</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/fast-test-for-double-lt-0-0-and-round-it-to-0-0/m-p/915976#M12594</link>
      <description>In such a situation, you may get better results from something similar to&lt;BR /&gt;time = t * dt;&lt;BR /&gt;Possibly faster might be to keep a double copy of t to use in this calculation.&lt;BR /&gt;&lt;BR /&gt;Setting abrupt underflow (e.g. by setting /Qftz in your compilation) might avoid accidental generation of such small non-zero numbers.&lt;BR /&gt;&lt;BR /&gt;When you use SSE2 or SSE3, your&lt;BR /&gt;if (time&amp;lt;0.0) time=0.0; &lt;BR /&gt;should compile to fast code (maxsd instruction, no branching).&lt;BR /&gt;</description>
      <pubDate>Sun, 24 Feb 2008 22:30:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/fast-test-for-double-lt-0-0-and-round-it-to-0-0/m-p/915976#M12594</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2008-02-24T22:30:21Z</dc:date>
    </item>
  </channel>
</rss>

