<?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>CodeWarrior for MCU中的主题 Re: cw v6.2 math precision</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179394#M6002</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Emac,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; You are great.Thank U...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I used this acos function &amp;amp; checked, Its working fine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the delayed response. Thank U once again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Oct 2010 19:55:18 GMT</pubDate>
    <dc:creator>ShivaSparrl</dc:creator>
    <dc:date>2010-10-19T19:55:18Z</dc:date>
    <item>
      <title>cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179370#M5978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working with cw 6.2, and trying do make some trigonometric calculations. The target is a MCF51qe.&lt;/P&gt;&lt;P&gt;For exemple, when I do this:&lt;/P&gt;&lt;P&gt;sin((double)0.86217507327430);&lt;/P&gt;&lt;P&gt;I obtain 0.75926020631887015.&lt;/P&gt;&lt;P&gt;In matlab, the same sinus gives 0.75925986842193.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The difference is not so big, but I have difference for each sin/cos calculation, and the result is used to found the distance between 2 GPS points. The distance is given using an acos function but the argument of the acos is &amp;gt;1, due to precision problems; so it can't be calculated. I'm sure of the formulas I'm using, as I checked with a computer and the problem doesn't appear (argument of acos is always&amp;lt;1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In cw, I have included this libs:&lt;/P&gt;&lt;P&gt;fp_coldfire_nodiv.a&lt;/P&gt;&lt;P&gt;C_4i_CF_RegABI_MATH_MSL.a&lt;/P&gt;&lt;P&gt;C_4i_CF_RegABI_Runtime.a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried other libs but without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Someone has an idea?&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2009 04:05:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179370#M5978</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2009-05-07T04:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179371#M5979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;0.5e-6 relative error is huge, not "not so big". That's normal performance for single precision FP, not for double!&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2009 20:02:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179371#M5979</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2009-05-07T20:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179372#M5980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nobody has an idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I compute the sinus in single precision, there is always a different between mcu and matlab result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2009 16:39:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179372#M5980</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2009-06-04T16:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179373#M5981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something is wrong with CW library, you should do a service request. If you can't wait for bugfixes, then you may try using&amp;nbsp;third party math functions.&amp;nbsp;Something like cephes lib at &lt;A href="http://www.netlib.org/" rel="nofollow" target="_blank"&gt;www.netlib.org&lt;/A&gt; should be more precise.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2009 19:45:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179373#M5981</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2009-06-04T19:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179374#M5982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks for your answer Kef. I will take a look at netlib.org and do a service request.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 13:46:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179374#M5982</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2009-06-05T13:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179375#M5983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I don't think the C standard enforces double to be 64 bytes. When creating a CW project you can decide whether you want double to be 32 bit (same as float) or 64 bit.&lt;BR /&gt;&lt;BR /&gt;Maybe this is the case here?&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 19:30:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179375#M5983</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2009-06-05T19:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179376#M5984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I have created the project, to the question:&lt;/P&gt;&lt;P&gt;"select if you want floating point support" I choose "float is ieee64, double is ieee64" .&lt;/P&gt;&lt;P&gt;this includes the foloowing libraries:&lt;/P&gt;&lt;P&gt;C_4i_CF_RegABI_MATH_MSL.a, C++_4i_CF_RegABI_MATH_MSL.a, Cpp_4i_CF_RegABI_Runtime.a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I choose&amp;nbsp; "no" to the question, the following libraries are included:&lt;/P&gt;&lt;P&gt;C_4i_CF_RegABI_MSL.a, C++_4i_CF_RegABI_MSL.a, Cpp_4i_CF_RegABI_Runtime.a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 20:36:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179376#M5984</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2009-06-05T20:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179377#M5985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can see I neglected to handle to negative (error case)&lt;/P&gt;&lt;PRE&gt;
  if(x &amp;lt; 0.0)  {    return(MY_DOUBLE_ERROR_IS_INFINITY);  }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or you can use identities to make x = x + 2pi if x &amp;lt; 0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:28:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179377#M5985</guid>
      <dc:creator>Emac</dc:creator>
      <dc:date>2020-10-29T09:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179378#M5986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer Emac.&lt;/P&gt;&lt;P&gt;I will try your sinus function. I also have to check if it is fast enough, as I have to do real time caclulation of GPS position.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2009 16:20:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179378#M5986</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2009-06-18T16:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179379#M5987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If need be, the number of terms can easily be scaled back if you need faster operation at the cost of less accuracy.&amp;nbsp; The current number of terms matched your matlab calculated value but perhaps fewer terms would work as well.&amp;nbsp; Also the constants could be better defined.&amp;nbsp;&amp;nbsp; The source of my numbers and constants was Excell - not known as being the ultimate mathmatical standard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jun 2009 02:10:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179379#M5987</guid>
      <dc:creator>Emac</dc:creator>
      <dc:date>2009-06-19T02:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179380#M5988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Final code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
/*This formula uses taylor integration expansion and the identity function to evaluatesine over the range of 0 to pi (and by trig identities, -2pi to 2 pi)error should be less than ~ 5e-10*/double mysin(double x){  double identityMatrix[]={-1.00000000000000000E+00,+1.00000000000000000E+00,-1.00000000000000000E+00,+1.00000000000000000E+00,-1.00000000000000000E+00,+1.00000000000000000E+00,-1.00000000000000000E+00};  double multiplierMatrix[] ={5.49450549450549450E-03, //  1/(14*13)7.57575757575757575E-03, //  1/(12*11)1.11111111111111111E-02, //  1/(10*9)1.78571428571428571E-02, //  1/(8*7)3.33333333333333333E-02, //  1/(6*5)8.33333333333333333E-02, //  1/(4*3)5.00000000000000000E-01  //  1/(2*1)};  double result;  double finalSign;  double innerTerm;  const double pi_over_2 = 1.57079632679490000E+00;  const double pi        = 3.14159265358979000E+00;  const double twoPi     = 6.28318530717959000E+00;#define MY_DOUBLE_ERROR_IS_INFINITY 0x7ff0000000000000  //handle negative numbers  if(x &amp;lt; 0.0)  {    x= x + twoPi;  }  //how do you want to handle an error (throw exception?)  if(x &amp;gt;= twoPi)  {    return(MY_DOUBLE_ERROR_IS_INFINITY);  }  if(x &amp;lt; 0.0)  {    return(MY_DOUBLE_ERROR_IS_INFINITY);  }  if( x &amp;lt; pi)  {    innerTerm = x -  pi_over_2;    innerTerm = innerTerm*innerTerm;    finalSign = (double) -1.0;  }else  {    innerTerm = x - pi -  pi_over_2;    innerTerm = innerTerm*innerTerm;    finalSign = (double) +1.0;  }  result = multiplierMatrix[0]*innerTerm + identityMatrix[0];  result = multiplierMatrix[1]*innerTerm*result + identityMatrix[1];  result = multiplierMatrix[2]*innerTerm*result + identityMatrix[2];  result = multiplierMatrix[3]*innerTerm*result + identityMatrix[3];  result = multiplierMatrix[4]*innerTerm*result + identityMatrix[4];  result = multiplierMatrix[5]*innerTerm*result + identityMatrix[5];  result = multiplierMatrix[6]*innerTerm*result + identityMatrix[6];  result = result * finalSign;  return(result);}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know if moderator could link to this code instead of broken one from before &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:28:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179380#M5988</guid>
      <dc:creator>Emac</dc:creator>
      <dc:date>2020-10-29T09:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179381#M5989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again Emac.&lt;/P&gt;&lt;P&gt;Your function is working well; I will search for the other trigonometric functions(cos, tan,acos,asin,atan), as I have the same problem with these functions.&lt;/P&gt;&lt;P&gt;I don't had the time to check the speed, but I will do it and let you know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2009 17:14:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179381#M5989</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2009-06-22T17:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179382#M5990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the response of the service request:&lt;/P&gt;&lt;PRE&gt;Dear Guillaume,&lt;/PRE&gt;&lt;PRE&gt;You are right, the MCF51QE128 isn't as accurate like the matlab
software, the reason is very simple, our mcu doesn't have a
multiplication or division unit, therefore there's the need to create
software routines (libraries) that implements such instructions.

That's the reason why matlab is more accurate, because at matlab all the
processing of information occurs at your computer, the MCF51QE isn't as
powerful like your computer core, but is cheaper and easier to
understand.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;For them, the problem is not the library but the MCF51...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:28:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179382#M5990</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2020-10-29T09:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179383#M5991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then they are not telling the thruth. MCF51 is as accurate as any other computer in the world. Inaccurate is their sin() routine. Their&amp;nbsp;double precision software mul, add, div etc are fine (I checked that if it matters).&lt;/P&gt;&lt;P&gt;It is not true also that MCF51 doesn't have hardware multiplication. It has. It doesn't have division, but division emulation on Coldfire V1 is pretty fast. Of course slower than with hardware division, but&amp;nbsp; not zilions of times.&lt;/P&gt;&lt;P&gt;I think you need accurate results first, then the execution speed. If you would need speed, you could use single precision of maybe fixed point routines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2009 17:49:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179383#M5991</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2009-06-22T17:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179384#M5992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with you Kef.&lt;/P&gt;&lt;P&gt;I have re-opened the service request.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2009 19:17:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179384#M5992</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2009-06-22T19:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179385#M5993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case you need a cos algorithem in the mean time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
/*This formula uses taylor integration expansion and the identity function to evaluatecosine over the range of pi/2 to 3pi/2 (and by trig identities, -2pi to 2 pi)error should be less than ~ 1e-10Inspiration from pg 81 tailor series expansion from Numerical Methods fo Engineersby Chapra &amp;amp; Canale Mcgraw Hill publishersa = pi (in order to use trig identities)*/double mycos(double x){  const double multiplierMatrix[] ={-5.49450549450549450E-03, //  -1/(14*13)-7.57575757575757576E-03, //  -1/(12*11)-1.11111111111111111E-02, //  -1/(10*9)-1.78571428571428571E-02, //  -1/(8*7)-3.33333333333333333E-02, //  -1/(6*5)-8.33333333333333333E-02, //  -1/(4*3)-5.00000000000000000E-01 //  -1/(2*1)};  double result;  double finalSign;  double innerTerm;  const double pi_over_2       = 1.57079632679490000E+00;  const double pi              = 3.14159265358979000E+00;  const double three_pi_over_2 = 4.71238898038469000E+00;  const double twoPi           = 6.28318530717959000E+00;#define MY_DOUBLE_ERROR_IS_INFINITY 0x7ff0000000000000  //handle negative numbers  if(x &amp;lt; 0.0)  {    x= x + twoPi;  }  //how do you want to handle an error (throw exception?)  if(x &amp;gt;= twoPi)  {    return(MY_DOUBLE_ERROR_IS_INFINITY);  }  if(x &amp;lt; 0.0)  {    return(MY_DOUBLE_ERROR_IS_INFINITY);  }  if( x &amp;lt; pi_over_2  )  {    innerTerm = x*x;    finalSign = (double) +1.0;  }else if( x &amp;lt; three_pi_over_2 )  {    innerTerm = x - pi;    innerTerm = innerTerm*innerTerm;    finalSign = (double) -1.0;  }else  {    innerTerm = x - twoPi;    innerTerm = innerTerm*innerTerm;    finalSign = (double) +1.0;  }  result = multiplierMatrix[0]*innerTerm        + 1.0;  result = multiplierMatrix[1]*innerTerm*result + 1.0;  result = multiplierMatrix[2]*innerTerm*result + 1.0;  result = multiplierMatrix[3]*innerTerm*result + 1.0;  result = multiplierMatrix[4]*innerTerm*result + 1.0;  result = multiplierMatrix[5]*innerTerm*result + 1.0;  result = multiplierMatrix[6]*innerTerm*result + 1.0;  result = result * finalSign;  return(result);}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:28:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179385#M5993</guid>
      <dc:creator>Emac</dc:creator>
      <dc:date>2020-10-29T09:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179386#M5994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know about your compiler library (I use 9s12 ) but the same people most likely did yours as did mine,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a conditional compilation statement the adds in additional precision&lt;/P&gt;&lt;P&gt;#if !_SIN_HUGE&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;#else&lt;/P&gt;&lt;P&gt;#ifdef EXTENDED_PRECISION_COSSIN&lt;/P&gt;&lt;P&gt;...&amp;nbsp; //some additional precision here&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;&amp;nbsp;... //more precision than original here&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;add this to your compiler options or define it in you first file and maybe the precision will come in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define _SIN_HUGE&lt;/P&gt;&lt;P&gt;#define EXTENDED_PRECISION_COSSIN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;note you may get enough accuracy from _SIN_HUGE alone and you may not need the EXTENDED_PRECISION_COSSIN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To me the "_" in "_SIN_HUGE" means that it is a system generated definition so you may have to check you options instead of forcing it like&amp;nbsp;I did above.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check your installation and look at the source file for the math.c file and dig in it to&amp;nbsp;see if you have a conditional compile as well.&amp;nbsp; Then be sure to do a clean compile by removing all of the object files first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... (my path for example) ...&lt;/P&gt;&lt;P&gt;C:\PROGRA~1\FREESC~1\CWFORH~1.5\lib\hc12c\src&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;note math.c is for double&lt;/P&gt;&lt;P&gt;mathf.c is for float&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2009 00:01:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179386#M5994</guid>
      <dc:creator>Emac</dc:creator>
      <dc:date>2009-06-25T00:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179387#M5995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your cosinus finction Emac, it will be usefull.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm quite lost with the libraries, as I'm not used to work with this; but I'm still looking if there is something about precision.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2009 14:12:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179387#M5995</guid>
      <dc:creator>Sanahuja</dc:creator>
      <dc:date>2009-06-29T14:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179388#M5996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Emac,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for posting the codes of sin, cos functions(double precision). Could u please post the code of acos function(double precision).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Waiting for ur reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Aug 2010 22:20:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179388#M5996</guid>
      <dc:creator>ShivaSparr</dc:creator>
      <dc:date>2010-08-14T22:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: cw v6.2 math precision</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179389#M5997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sanahuja,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also facing the similar problem which u were facing, i want to find the distance between 2 GPS points.&lt;/P&gt;&lt;P&gt;I have used the code of sin, cos functions(double precision),which Emac had posted &amp;amp; its working. But i also need the acos function(double precision). So please post the code acos function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Waiting for ur reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Aug 2010 22:25:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/cw-v6-2-math-precision/m-p/179389#M5997</guid>
      <dc:creator>ShivaSparr</dc:creator>
      <dc:date>2010-08-14T22:25:57Z</dc:date>
    </item>
  </channel>
</rss>

