Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: short int always 16 bits or not? (http://www.velocityreviews.com/forums/t959940-re-short-int-always-16-bits-or-not.html)

Les Cargill 04-20-2013 05:24 AM

Re: short int always 16 bits or not?
 
Shriramana Sharma wrote:
> Hello. I am reading the C99 standard as available from:
> http://www.open-std.org/jtc1/sc22/WG...docs/n1256.pdf
>
> I note that it specifies (on p 34) macros defining the minimum and
> maximum values of a short int corresponding to a size of 16 bits.
> However it doesn't explicitly say that short int-s should be of 16
> bits size. So can I trust short int-s to be 16 bits size or not?
>


No, not really. You have to verify this. This being said,
it's true for a vast majority of platforms.

> Also, doesn't prescribing #define-s for integer type min/max values
> conflict with the general (?) understanding that the size of these
> types are implementation defined? I mean, is the general
> understanding wrong? (For instance see:
> http://en.wikipedia.org/wiki/Short_i...e_b_grp_notesc)
>


Supposedly, said macros would be adapted to be platform specific.

> Finally, why would anyone want char to be other than 8 bits? *Is*
> char on any platform *not* 8 bits?
>


We can't say in general. It's a heck of a founding assumption
to give up, so hopefully there's a good reason.

> Thanks.
>


--
Les Cargill


All times are GMT. The time now is 02:00 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.