<?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: Which is faster: floating point division or casting to 64-bit int? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1327986#M61321</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/1452"&gt;@BlackNight&lt;/a&gt;&amp;nbsp;- You previously provided the accepted solution to this post. For some reason NXP has removed that solution. Is there any chance you still have the your original post to this question? Would you mind re-sharing it? Thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Aug 2021 19:25:32 GMT</pubDate>
    <dc:creator>aberger</dc:creator>
    <dc:date>2021-08-23T19:25:32Z</dc:date>
    <item>
      <title>Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/797009#M48469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consider the simple calculation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;result = (A/B)*scaleFactor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where all quantities are unsigned, 32-bit integers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A/B is strictly less than 1,&amp;nbsp;&lt;EM&gt;but&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;A*scaleFactor could be larger than 2^32.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore, it seems I have two options:&lt;/P&gt;&lt;P&gt;result = ((float)(A)/B)*scaleFactor&lt;/P&gt;&lt;P&gt;&lt;EM&gt;or&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;result = ((uint64_t)(A)*scaleFactor)/B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which sequence of operations is faster on the K64?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Aug 2018 23:33:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/797009#M48469</guid>
      <dc:creator>aberger</dc:creator>
      <dc:date>2018-08-17T23:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/797011#M48471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Erich, this is great. At this time, I'm using the P&amp;amp;E debugger in MCUXpresso, so it unfortunately looks like I can't do the DWT cycle counting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Aug 2018 19:12:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/797011#M48471</guid>
      <dc:creator>aberger</dc:creator>
      <dc:date>2018-08-20T19:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/797012#M48472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, that's currently only supported with the LinkServer connection. For P&amp;amp;E you could directly read the DWT cycle counter in the memory view or store the values in your code, see &lt;A class="link-titled" href="https://mcuoneclipse.com/2017/01/30/cycle-counting-on-arm-cortex-m-with-dwt/" title="https://mcuoneclipse.com/2017/01/30/cycle-counting-on-arm-cortex-m-with-dwt/"&gt;Cycle Counting on ARM Cortex-M with DWT | MCU on Eclipse&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2018 13:47:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/797012#M48472</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2018-08-21T13:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1324000#M61238</link>
      <description>&lt;P&gt;Why did the solution to this discussion vanish?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 16:36:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1324000#M61238</guid>
      <dc:creator>aberger</dc:creator>
      <dc:date>2021-08-16T16:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1327986#M61321</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/1452"&gt;@BlackNight&lt;/a&gt;&amp;nbsp;- You previously provided the accepted solution to this post. For some reason NXP has removed that solution. Is there any chance you still have the your original post to this question? Would you mind re-sharing it? Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 19:25:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1327986#M61321</guid>
      <dc:creator>aberger</dc:creator>
      <dc:date>2021-08-23T19:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1328753#M61326</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/113456"&gt;@aberger&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/1452"&gt;@BlackNight&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;What happened to this thread?&amp;nbsp; I'd be interested in the comments.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 15:31:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1328753#M61326</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-08-24T15:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1328821#M61328</link>
      <description>&lt;P&gt;I have no idea. I even cannot display the content of this thread, all what I get is&lt;/P&gt;&lt;P&gt;"This widget could not be displayed."&lt;/P&gt;&lt;P&gt;&lt;LI-EMOJI id="lia_disappointed-face" title=":disappointed_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 16:57:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1328821#M61328</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-08-24T16:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1328822#M61329</link>
      <description>&lt;P&gt;Not sure what could have been the original solution, but a while back I wrote about this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/" target="_blank"&gt;https://mcuoneclipse.com/2019/03/29/be-aware-floating-point-operations-on-arm-cortex-m4f/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 17:00:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1328822#M61329</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-08-24T17:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Which is faster: floating point division or casting to 64-bit int?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1328867#M61331</link>
      <description>&lt;P&gt;I was able to find this partial response by digging into the web page source:&lt;/P&gt;&lt;P&gt;My guess was that your first version with the single precision float operation will be faster, as the ARM Cortex-M4F can use the FPU for this, while your 64bit version requires a library runtime routine which very likely is slower. All depends to some extend to compiler optimizations and value of da...&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 18:35:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Which-is-faster-floating-point-division-or-casting-to-64-bit-int/m-p/1328867#M61331</guid>
      <dc:creator>aberger</dc:creator>
      <dc:date>2021-08-24T18:35:58Z</dc:date>
    </item>
  </channel>
</rss>

