Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Size of data types in C?

Reply
Thread Tools

Size of data types in C?

 
 
vivek.sriwastava@gmail.com
Guest
Posts: n/a
 
      10-11-2005
hi,
It is basicaly decided by the compiler.
OS simply provide the base for the compiler and nothing else . But it
is mutual because if OS is not capable enough to handle the request of
compiler then it is not possible for compiler to get done any work.
For example turbo C takes only two bytes in case of int while VC++
takes 4 byte fopr the same int.
Or take one more example of java for the same platform turbo C
allocate only two byte while java allocate 4 bytes.

 
Reply With Quote
 
 
 
 
Emmanuel Delahaye
Guest
Posts: n/a
 
      10-11-2005
siliconwafer a écrit :
> Who decides size of data types in C?
> Is it the:
> 1.C standard and hence the compilers
> 2.Operating System.
>


It's more subtle...

- The C-standard doen't define the data types i terms of width but
rather in terms of range. It gives minimum ranges for each type :

Type Minimum Maximum
char 0 127
unsigned char 0 255
signed char -127 127
[signed] short -32767 32767
usigned short 0 65535
[signed] int -32767 32767
unsigned [int] 0 65535
[signed] long [int] -2147483647 2147483647
unsigned long [int] 0 4294967295

[fixed font required]

- The implementation (the processor and the way it is used by the
system) fixes the actual number of bits of each type, so that the
minimum C-requirements are reached.

For example:

x86 real and extended mode (BIOS, MS-DOS, Windows 3x):

char is 8-bit
short is 16-bit
int is 16-bit
long is 32-bit

Same processor but in protected mode (aka '32-bit') as used by Win32,
Linux etc.:

char is 8-bit
short is 16-bit
int is 32-bit
long is 32-bit

Now, if you play with a Texas Instrument DSP like TMS320C54:

char is 16-bit
short is 16-bit
int is 16-bit
long is 32-bit

etc. It depends on the hardware capabilities.
 
Reply With Quote
 
 
 
 
Antonio Contreras
Guest
Posts: n/a
 
      10-11-2005
Walter Roberson wrote:
> In article <(E-Mail Removed)>,
> Keith Thompson <(E-Mail Removed)> wrote:
> >(E-Mail Removed) (Richard Tobin) writes:

>
> >> Nothing stops you writing a C compiler for Linux that provides 17-bit
> >> ints and 18 bit pointers, but you won't sell many.

>
> >If by "17-bit ints" you mean, say, 18-bit ints with 1 padding bit,
> >that's true, as long as CHAR_BIT is either 9 or 18.

>
> But it's *Linux*, so you aren't going to -sell- many of *anything*
> (discounting the "Linux for Dummies" books and the Slashdot
> merchandise.)


Arguable.

> Some of my co-workers are modelling the spread of infectious diseases.
> (Seriously so.) As best I can tell, the same techniques can be
> used to model the spread of Linux.


Or the spread of technological innovations (movile phones, digital
cameras...), or the spread of nenufars in a lake, or the growth rate of
a bacteria population, or the spread of hoaxes over email users, or the
spread of ...

The logistical equation can be applied in many many situations.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
equivalent c data types for vc++ data types ramu C Programming 2 02-20-2006 09:33 AM
size of a class having enumerated data types? ypjofficial@indiatimes.com C++ 8 01-23-2006 12:29 PM
On what does size of data types depend? Sunil C Programming 35 10-12-2005 01:35 AM



Advertisments