<?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 ? operator warning in CodeWarrior Development Tools</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/operator-warning/m-p/385858#M2275</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;signed char X1,X2,X3;&lt;/P&gt;&lt;P&gt;X3 = (X1 &amp;gt; X2)? 127: -128;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;When i compile this code, the compiler display warning message said "&lt;/SPAN&gt;&lt;SPAN style="color: #333333; font-family: arial; font-size: 14px; background-color: #fefefe;"&gt;possible &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;lost of data".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But compile the code "&lt;SPAN style="font-size: 13.3333330154419px;"&gt;X3 = (X1 &amp;gt; X2)? 127: -127;" is ok.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So do that "signed short" with -32768, and "signed long" with -2147483648&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why? Is this a compiler's Bug?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Apr 2015 07:45:48 GMT</pubDate>
    <dc:creator>markulhu</dc:creator>
    <dc:date>2015-04-08T07:45:48Z</dc:date>
    <item>
      <title>? operator warning</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/operator-warning/m-p/385858#M2275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;signed char X1,X2,X3;&lt;/P&gt;&lt;P&gt;X3 = (X1 &amp;gt; X2)? 127: -128;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;When i compile this code, the compiler display warning message said "&lt;/SPAN&gt;&lt;SPAN style="color: #333333; font-family: arial; font-size: 14px; background-color: #fefefe;"&gt;possible &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;lost of data".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But compile the code "&lt;SPAN style="font-size: 13.3333330154419px;"&gt;X3 = (X1 &amp;gt; X2)? 127: -127;" is ok.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So do that "signed short" with -32768, and "signed long" with -2147483648&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why? Is this a compiler's Bug?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2015 07:45:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/operator-warning/m-p/385858#M2275</guid>
      <dc:creator>markulhu</dc:creator>
      <dc:date>2015-04-08T07:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: ? operator warning</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/operator-warning/m-p/385859#M2276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the compiler is a little bit over-cautious here: -128 gets promoted to int, which is 0xffff'8000 (as 16bit int), and then truncated back to signed char with the assignment.&lt;/P&gt;&lt;P&gt;So the compiler warns about these uppper 8bits lost (which are not really an issue).&lt;/P&gt;&lt;P&gt;You can get rid of that warning with a cast like this:&lt;/P&gt;&lt;P&gt;X3 = (signed char)((X1 &amp;gt; X2)? 127: -128);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2015 08:20:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/operator-warning/m-p/385859#M2276</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2015-04-08T08:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: ? operator warning</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/operator-warning/m-p/385860#M2277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;P&gt;Thank you Erich Styger!&lt;/P&gt;&lt;P&gt;Today,i tring to compile code "signed long X1 = -2147483648"(0x8000 0000), the complier warning: Unary minus operator appiled to unsigned type.&lt;/P&gt;&lt;P&gt;just "signed long X1 = 0x80000000"is the right way?&lt;/P&gt;&lt;P&gt;How about your idea?&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 03:13:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/operator-warning/m-p/385860#M2277</guid>
      <dc:creator>markulhu</dc:creator>
      <dc:date>2015-04-09T03:13:28Z</dc:date>
    </item>
  </channel>
</rss>

