<?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: Other Crazy result for math operations!!?</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195842#M7232</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;It doesn't give the wrong result. You are using the bitwise XOR operator ^. C only supports x raised by y for float numbers with the pow() function.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Oct 2008 14:01:40 GMT</pubDate>
    <dc:creator>Lundin</dc:creator>
    <dc:date>2008-10-22T14:01:40Z</dc:date>
    <item>
      <title>Other Crazy result for math operations!!?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195838#M7228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have this problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;two unsigned int:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;UmidRisult = 631;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TempCalcolo = UmidRisult * 4;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TempCalcolo=....6584!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I dont understand why!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ScreenShot:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://digilander.libero.it/ciccio.unico/image1.jpg"&gt;&lt;IMG src="http://digilander.libero.it/ciccio.unico/image1.jpg" /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2008 20:41:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195838#M7228</guid>
      <dc:creator>cicciounico</dc:creator>
      <dc:date>2008-10-21T20:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Other Crazy result for math operations!!?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195839#M7229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Hello cicciounico,&lt;BR /&gt;&lt;BR /&gt;I'd suggest you to check if the value UmidRisult shown by debugger is correct .&amp;nbsp; Is indeed 631? You may step into SHT_Measure() to see the exact result.&lt;BR /&gt;I guess this might be also caused by C optimization switched on. Is the result of the expression correct at the end of the function? If yes then try to turn the compiler optimization off and debug it once more?&lt;BR /&gt;&lt;BR /&gt;Stanish&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2008 21:53:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195839#M7229</guid>
      <dc:creator>stanish</dc:creator>
      <dc:date>2008-10-21T21:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Other Crazy result for math operations!!?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195840#M7230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Good!&lt;BR /&gt;I have removed the optimization ( -O0 ) and now work!&lt;BR /&gt;&lt;BR /&gt;After I have removed also&amp;nbsp; '^2' : this does wrong result!&lt;BR /&gt;&lt;BR /&gt;Original:&lt;BR /&gt;UmidRisult = (-(((((Temp/25)^2)/16)*(28))/10) + Temp*4 - 400)/100;&lt;BR /&gt;&lt;BR /&gt;transformed in:&lt;BR /&gt;&lt;BR /&gt;TempCalcolo&amp;nbsp;&amp;nbsp;&amp;nbsp; = (Temp * 4) - 400;&lt;BR /&gt;TempCalcoloDue = ((Temp/25)*(Temp/25));&lt;BR /&gt;UmidRisult = (-((((TempCalcoloDue)/16)*(28))/10) + TempCalcolo)/100;&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!!!&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2008 22:15:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195840#M7230</guid>
      <dc:creator>cicciounico</dc:creator>
      <dc:date>2008-10-21T22:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Other Crazy result for math operations!!?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195841#M7231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It would seem that the value of Temp would correspond with a 12-bit range (0-4095).&amp;nbsp; Is this correct?&amp;nbsp; If so, the integer&amp;nbsp;calculation for UmidRisult would overflow a signed integer value, at an intermediate point in the calculation, should the value of Temp exceed 3400.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2008 06:30:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195841#M7231</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-10-22T06:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Other Crazy result for math operations!!?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195842#M7232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;It doesn't give the wrong result. You are using the bitwise XOR operator ^. C only supports x raised by y for float numbers with the pow() function.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2008 14:01:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195842#M7232</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-10-22T14:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Other Crazy result for math operations!!?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195843#M7233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Reply bigmac: the sensor humidity (sensirion) cannot go over 3400. At 3350 = 100,234% of humidity&lt;BR /&gt;Reply Lundin: right! I was wrong. '^' is XOR and not POW&lt;BR /&gt;&lt;A href="http://forums.freescale.com/../view_profile?user.id=1301" rel="nofollow" target="_blank"&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2008 14:53:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Other-Crazy-result-for-math-operations/m-p/195843#M7233</guid>
      <dc:creator>cicciounico</dc:creator>
      <dc:date>2008-10-22T14:53:42Z</dc:date>
    </item>
  </channel>
</rss>

