<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>C51 750 compile bug!</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/18065/c51-750-compile-bug</link><description> volatile unsigned int Wi; 
 
 Wi= (0x4000*3)/(0x10); 
 
//The compliler will make Wi = 0xfc00 !! 
//The right answere is Wi = 0x0c00!! </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: C51 750 compile bug!</title><link>https://community.arm.com/thread/122909?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2005 03:19:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:14f7b587-b983-43eb-966d-b63a62a1de15</guid><dc:creator>G Richard</dc:creator><description>&lt;p&gt;Thank you everybody!!!&lt;br /&gt;
Thank you very much for your answer!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C51 750 compile bug!</title><link>https://community.arm.com/thread/111593?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2005 21:43:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:16d7790e-ce7c-4cd0-8222-c14602403d9d</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;&lt;i&gt;A constand of 0xb000, however, is unsigned in 16-bit ANSI C compilers. Getting this right might require the &amp;quot;apply ANSI integer promotions&amp;quot; switch of C51 to be active.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Refer to 6.3.1.8 Usual arithmetic conversions in the ANSI spec for what&amp;#39;s actually happening in the case mentioned.  In this situation, the result being a signed int is correct.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C51 750 compile bug!</title><link>https://community.arm.com/thread/111595?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2005 11:42:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d2dfdd57-b2e6-4cd7-a3f3-f826c5897fc7</guid><dc:creator>Karl Hamsher</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Getting this right might require the &amp;quot;apply ANSI integer promotions&amp;quot; switch of C51 to be active.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Or simply being explicit:&lt;br /&gt;
&lt;br /&gt;
0x4000U&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C51 750 compile bug!</title><link>https://community.arm.com/thread/97370?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2005 11:30:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e2e3f063-1518-4f74-8613-4502e320463b</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;There&amp;#39;s a possible loophole in this argument though, which might explain the OP&amp;#39;s bewilderment: 0x4000 is signed int alright.  A constand of 0xb000, however, is unsigned in 16-bit ANSI C compilers.  Getting this right might require the &amp;quot;apply ANSI integer promotions&amp;quot; switch of C51 to be active.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C51 750 compile bug!</title><link>https://community.arm.com/thread/87336?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2005 11:09:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2e50546d-978a-4348-945f-98696b164a4e</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;&lt;i&gt;Keil defaults int operations and int represetation of numbers&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Actually, that&amp;#39;s an ANSI specification.  So, all C compilers with 16-bit int types should do this.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: C51 750 compile bug!</title><link>https://community.arm.com/thread/44491?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2005 06:32:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4e24232a-fbe5-41d0-8433-f4decf92212c</guid><dc:creator>Roman Horvath</dc:creator><description>&lt;p&gt;This is not bug. Keil defaults int operations and int represetation of numbers. After 0x4000*3 the int overflows to 0xc000, which is -0x4000, (-16384 in decimal) . after /10 the result is -1024 in decimal which is 0xfc00.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>