<?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: nonIEEEconform floats in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154769#M3889</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've added the issue as MTWX38839 in the internal bug database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Nov 2009 03:16:58 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2009-11-17T03:16:58Z</dc:date>
    <item>
      <title>nonIEEEconform floats</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154766#M3886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;working with CW 6.1 and a MC13213 i ran into problems with the floatingLib.&lt;/P&gt;&lt;P&gt;I constructed a snippet&amp;nbsp; that brings up the kind of problem. (even in the true-time-simulation)&lt;/P&gt;&lt;P&gt;I calculate x3 = (2.5e-11) - (1.7e-20)*(1.7e-20).&lt;/P&gt;&lt;P&gt;and would expect one of the following:&lt;/P&gt;&lt;P&gt;2.5e-11 (plus minus some rounding error), or NaN, or +Inf , or -Inf.&lt;/P&gt;&lt;P&gt;But I get: x3==-3.34...e+37&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is not conform to IEEE 754 as far as i can see.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already tried using a Service Request, but it got closed.&lt;/P&gt;&lt;P&gt;And i have no solution to the problem yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Q1: are you able to reproduce the behavior?&lt;/P&gt;&lt;P&gt;Q2: can you understand, why i expect a different result?&lt;/P&gt;&lt;P&gt;Q3: is this conform to IEEE in your opinion?&lt;/P&gt;&lt;P&gt;Q4: do you know a solution?&lt;/P&gt;&lt;P&gt;Aswers to any of these Questions is welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp; Fabian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;int main(){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;volatile float x1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;volatile float x2a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;volatile float x2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;volatile float x3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x1=2.5e-11; /** this is within normalized range **/&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x2a=1.7e-20; /** this is within normalized range **/&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x2 = x2a*x2a; /** this is within denormalized IEEE754&lt;BR /&gt;range **/&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x3=x1-x2;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /** this goes wrong i think **/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SOPT_COPE=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while( x3&amp;lt;0 ); /** this halts, but should not **/&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;; /** this should halt but is never reached **/&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2009 16:27:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154766#M3886</guid>
      <dc:creator>fak</dc:creator>
      <dc:date>2009-11-16T16:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: nonIEEEconform floats</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154767#M3887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;I calculate x3 = (2.5e-11) - (1.7e-20)*(1.7e-20).&lt;/P&gt;&lt;P&gt;and would expect one of the following:&lt;/P&gt;&lt;P&gt;2.5e-11 (plus minus some rounding error), or NaN, or +Inf , or -Inf.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;2.5e-11 is&amp;nbsp;the right answer. NaN and Inf would be wrong.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;But I get: x3==-3.34...e+37&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;With CW6.3 I got -2.889996e-040 (- (1.7e-20) ^2 ) , which is also wrong.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is not conform to IEEE 754 as far as i can see.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Of course.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already tried using a Service Request, but it got closed.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;not good&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;And i have no solution to the problem yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Q1: are you able to reproduce the behavior?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes. Different answer but also wrong.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Q2: can you understand, why i expect a different result?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Of course yes.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Q3: is this conform to IEEE in your opinion?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;No&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Q4: do you know a solution?&lt;/P&gt;&lt;P&gt;Aswers to any of these Questions is welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It can be solved this way 1) testing&amp;nbsp;existing FP routines implementation for IEEE conformance.&amp;nbsp;Everything can be found here:&amp;nbsp;&amp;nbsp;&lt;A href="http://www.math.utah.edu/~beebe/software/ieee/" rel="nofollow" target="_blank"&gt;http://www.math.utah.edu/~beebe/software/ieee/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2a) Using slow but already tested&amp;nbsp;SoftFloat &lt;A href="http://www.jhauser.us/arithmetic/SoftFloat.html" rel="nofollow" target="_blank"&gt;http://www.jhauser.us/arithmetic/SoftFloat.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2b) rolling your own FP emulation routines and testing them at least with W.M.Kahan's Paranoia.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2009 18:05:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154767#M3887</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2009-11-16T18:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: nonIEEEconform floats</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154768#M3888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why did support close the service request?&lt;/P&gt;&lt;P&gt;Getting completely off results seems just wrong to me &lt;IMG alt="Smiley Sad" class="emoticon emoticon-smileysad" id="smileysad" src="https://community.nxp.com/i/smilies/16x16_smiley-sad.png" title="Smiley Sad" /&gt;.&lt;/P&gt;&lt;P&gt;Can you try to reopen it? With such a simple snippet to reproduce it, it should not be hard to fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When stepping through the code the BCS in _FADD_K_is_K_plus_L seems wrong to me.&lt;/P&gt;&lt;P&gt;It does a unsigned 16 bit comparison of the exponents, but the exponents are negative for denormalized numbers, therefore the comparison should be signed.&lt;/P&gt;&lt;P&gt;See below for a quick (and just with a few samples tested...) fix for the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW: Same issue for double (64 bit).&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;PRE&gt;
ADDKL_Normal:                        ; // L and K are not special (means not 0,NAN,inf)
              LDA     Kexp:1
              SUB     Lexp:1
              TAX
              LDA     Kexp:0
              SBC     Lexp:0

&lt;SPAN&gt;// Use a signed comparison, Kexp and Lexp are both signed, &amp;lt; 0 for denormalized numbers
              BLT     ADDKL_0   ; // K:exp &amp;lt; L:exp
//            BCS     ADDKL_0   ; // K:exp &amp;lt; L:exp
&lt;/SPAN&gt;              TXA
              BEQ     ADDKL_1   ; // K:exp &amp;gt;= L:exp
              TST     Kexp:0    ; // R2780 negative Kexp not handled!
              BLT     ADDKL_0   ; // K:exp &amp;lt; L:exp
    ADDKL_3:  ;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:58:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154768#M3888</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2020-10-29T08:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: nonIEEEconform floats</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154769#M3889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've added the issue as MTWX38839 in the internal bug database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2009 03:16:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154769#M3889</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-11-17T03:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: nonIEEEconform floats</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154770#M3890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As note, to use the fixed code snippet, copy {}/lib/hc08c/src/rtshc08.c to your project,&lt;/P&gt;&lt;P&gt;add it to your project and then move it in the link order above the ANSI library.&lt;/P&gt;&lt;P&gt;Then in the local rtshc08.c search and replace the pattern as shown in the previous posting.&lt;/P&gt;&lt;P&gt;It occurs twice, once for 32 bit floats and once for 64 bit doubles. Then compile and link.&lt;/P&gt;&lt;P&gt;Make sure in the map file that the modified rtshc08.c is taken, and not the one out of the ANSI library&lt;/P&gt;&lt;P&gt;(fix the link order if the one from the ANSI library is still used).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2009 03:34:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/nonIEEEconform-floats/m-p/154770#M3890</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-11-17T03:34:29Z</dc:date>
    </item>
  </channel>
</rss>

