<?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 Standard C math functions fail in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Standard-C-math-functions-fail/m-p/139589#M2188</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm working with a ColdFire MCF5484 running Linux 2.6.10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using CodeWarrior for ColdFire ISA, Linux Platform Ed. v 2.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The standard math library calls (sin(), cos(), log10(), etc) have been giving me bogus answers. A simple example: log10(100.0) returns "-inf" (and not 2).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another observation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#include&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;static double getPI2() { return M_PI/2.0); }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;static double getV() {return 1.0; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;int main(int argc, char** argv)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;double v1 = sin(M_PI_2);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;double v2 = 1.0 * sin(getPI2());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;double v3 = getV() * sin(getPI2());&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;printf("%f, %f, %f\n", v1, v2, v3);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Produces:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"1.000000, 1.000000, -0.000000"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is it about calling a function that would corrupt a simple calculation like this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see the same problem on both the Logic PD ColdFire dev kit (M5485EVB) and our hardware. Do I need to explicitly enable floating point support somewhere? Is there a patch for CodeWarrior?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought the MCF548x had all sorts of great hardware floating point support, including multiply/accumulate instructions. Very confused and frustrated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Dec 2006 01:16:38 GMT</pubDate>
    <dc:creator>Wilson</dc:creator>
    <dc:date>2006-12-12T01:16:38Z</dc:date>
    <item>
      <title>Standard C math functions fail</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Standard-C-math-functions-fail/m-p/139589#M2188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm working with a ColdFire MCF5484 running Linux 2.6.10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using CodeWarrior for ColdFire ISA, Linux Platform Ed. v 2.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The standard math library calls (sin(), cos(), log10(), etc) have been giving me bogus answers. A simple example: log10(100.0) returns "-inf" (and not 2).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another observation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#include&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;static double getPI2() { return M_PI/2.0); }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;static double getV() {return 1.0; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;int main(int argc, char** argv)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;double v1 = sin(M_PI_2);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;double v2 = 1.0 * sin(getPI2());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;double v3 = getV() * sin(getPI2());&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;printf("%f, %f, %f\n", v1, v2, v3);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Produces:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"1.000000, 1.000000, -0.000000"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is it about calling a function that would corrupt a simple calculation like this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see the same problem on both the Logic PD ColdFire dev kit (M5485EVB) and our hardware. Do I need to explicitly enable floating point support somewhere? Is there a patch for CodeWarrior?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought the MCF548x had all sorts of great hardware floating point support, including multiply/accumulate instructions. Very confused and frustrated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 01:16:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Standard-C-math-functions-fail/m-p/139589#M2188</guid>
      <dc:creator>Wilson</dc:creator>
      <dc:date>2006-12-12T01:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Standard C math functions fail</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Standard-C-math-functions-fail/m-p/139590#M2189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I ran into the same problem,&lt;BR /&gt;&lt;BR /&gt;Does CodeWarrior use gcc3.4? The 3.4 seems to target the m68k which does not include the advanced math support.&lt;BR /&gt;&lt;BR /&gt;I am currently using gcc4.1 supplied by &lt;A href="http://www.codesourcery.com" target="test_blank"&gt;http://www.codesourcery.com&lt;/A&gt; It works great with the math support, and my applications runs noticably faster.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Dec 2006 23:15:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Standard-C-math-functions-fail/m-p/139590#M2189</guid>
      <dc:creator>MattSPI</dc:creator>
      <dc:date>2006-12-13T23:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Standard C math functions fail</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Standard-C-math-functions-fail/m-p/139591#M2190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I have the same problem with MCF5485 and codewarrior 6.4 for floating point functions.&lt;BR /&gt;I add this library (C_4i_CF_FPU_MSL.a ) to my project.&lt;BR /&gt;sqrt( ) works properly but sin( ) and cos( ) doesn't work?&lt;BR /&gt;Is it the problem of compiler or library ?&lt;BR /&gt;if so, Is this problem solved in codewarrrior 7.0?&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 31 Aug 2008 19:04:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Standard-C-math-functions-fail/m-p/139591#M2190</guid>
      <dc:creator>mkhademism</dc:creator>
      <dc:date>2008-08-31T19:04:41Z</dc:date>
    </item>
  </channel>
</rss>

