<?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>difference between short and char</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/15534/difference-between-short-and-char</link><description> Hi all, 
 
What is the difference between the data types char and short? According to the book, they are both 8 bits and have the exact same range. 
 
Thanks, 
Steve </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: difference between short and char</title><link>https://community.arm.com/thread/110255?ContentTypeID=1</link><pubDate>Fri, 07 Mar 2003 12:34:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6c446abf-aa55-46f6-99b5-e68740ec70bf</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;&lt;br /&gt;
I also am not fond of the UBYTE / UWORD style.  &amp;quot;WORD&amp;quot;, in particular, is really problematic.  It ought to mean the natural bus width of the machine -- probably the data bus -- but a lot of people use it to mean &amp;quot;16 bits&amp;quot;, even on eight- or 32-bit machines.  (And then they proceed to use DWORD to mean &amp;quot;32 bits&amp;quot;, since it&amp;#39;s twice a &amp;quot;WORD&amp;quot;.)  Then you stack that usage on top of some hardware device that has a different word width, and also keeps using the word &amp;quot;WORD&amp;quot; in their documentation and/or sample code.  Just too confusing, especially since the whole point of the series of typedefs is to give you a way to specify a known, exact, width.&lt;br /&gt;
&lt;br /&gt;
C99 has standardized a scheme in &amp;lt;inttypes.h&amp;gt; that serves this purpose -- uint8_t, etc.  I&amp;#39;m still trying to talk myself into learning to use it; I&amp;#39;ve gotten too settled in &amp;quot;my&amp;quot; way.  Besides, I dislike the &amp;quot;_t&amp;quot; ANSI-ism.  (I know it&amp;#39;s a type name, okay?  That&amp;#39;s why it comes in front of the variable name or inside the cast...  You don&amp;#39;t have to bludgeon me about the head and shoulders with the fact.)&lt;br /&gt;
&lt;br /&gt;
As always, it boils down to whatever works for you.&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: difference between short and char</title><link>https://community.arm.com/thread/84394?ContentTypeID=1</link><pubDate>Fri, 07 Mar 2003 09:39:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c10537cf-5184-4ba2-a919-3fbc67e9d53a</guid><dc:creator>Steve Foschino</dc:creator><description>&lt;p&gt;Thats kindda what I thought....just symantics, but I just wanted to make sure.  Thanks for the help&lt;br /&gt;
&lt;br /&gt;
Steve&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: difference between short and char</title><link>https://community.arm.com/thread/55085?ContentTypeID=1</link><pubDate>Thu, 06 Mar 2003 18:27:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b01c9fea-3894-4233-83e1-fe86c972d6fc</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Of course, there&amp;#39;s lots of variation: uint8, UBYTE / UWORD / ULONG, and so on.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Absolutely - after all, they&amp;#39;re just names!&lt;br /&gt;
&lt;br /&gt;
However, things like &amp;quot;Word&amp;quot;, &amp;quot;DWord&amp;quot;, &amp;quot;Long&amp;quot;, &lt;i&gt;etc&lt;/i&gt; have the definite disadvantage that they are &lt;b&gt;ambiguous&lt;/b&gt;: they do not &lt;i&gt;&lt;b&gt;explicitly&lt;/b&gt;&lt;/i&gt; state the size of the object - which is, after all, the whole point of the excercise!&lt;br /&gt;
&lt;br /&gt;
Therefore I always use and recommend (as a &amp;#39;Search&amp;#39; will show!) &lt;b&gt;U8&lt;/b&gt;, &lt;b&gt;S16&lt;/b&gt;, &lt;i&gt;etc&lt;/i&gt; -  as they show both size and signed-ness clearly, explicitly, and succinctly.&lt;br /&gt;
What more could you want?!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: difference between short and char</title><link>https://community.arm.com/thread/39889?ContentTypeID=1</link><pubDate>Thu, 06 Mar 2003 12:30:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3e4b0f09-8fe1-42b8-ae05-c985aea0f321</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;&lt;br /&gt;
Which book?  My C51 compiler manual PDF (version 7.02) says that a short is 16 bits.&lt;br /&gt;
&lt;br /&gt;
ANSI C requires a short to be at least 16 bits, and a long to be at least 32.&lt;br /&gt;
&lt;br /&gt;
In any event, if a short were 8 bits wide, it would be the same as a char -- just as in actuality, a &amp;quot;short&amp;quot; is the same as an &amp;quot;int&amp;quot; on this particular compiler.&lt;br /&gt;
&lt;br /&gt;
Most programmers I know adopted a habit of typedef&amp;#39;ing specific integer sizes as appropriate for their platform, and then using those typedefs instead.  Something along the lines of:&lt;br /&gt;
&lt;br /&gt;
typedef unsigned char  U8;&lt;br /&gt;
typedef   signed char  S8;&lt;br /&gt;
typedef unsigned short U16;&lt;br /&gt;
typedef   signed short S16;&lt;br /&gt;
typedef unsigned long  U32;&lt;br /&gt;
typedef   signed long  S32;&lt;br /&gt;
&lt;br /&gt;
That way you always know what you&amp;#39;re dealing with, and don&amp;#39;t have as much trauma moving from platform to platform.  Of course, there&amp;#39;s lots of variation: uint8, UBYTE / UWORD / ULONG, and so on.&lt;br /&gt;
&lt;br /&gt;
The ISO C99 standard also has a bunch of new integer types in &amp;lt;inttypes.h&amp;gt;, which serve the same purpose, among others.  (intptr_t, for instance: an integer guaranteed to be long enough to hold a pointer).&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: difference between short and char</title><link>https://community.arm.com/thread/39897?ContentTypeID=1</link><pubDate>Thu, 06 Mar 2003 12:27:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3a898fa3-e5ed-4c0c-9e89-6fc2853e4cf6</guid><dc:creator>Steve Foschino</dc:creator><description>&lt;p&gt;oops, my bad.....&lt;br /&gt;
&lt;br /&gt;
I meant to say the difference between short and int.  They are both 16 bits.  Is it just a symantic difference?&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;
Steve&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>