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?

 
 
siliconwafer
Guest
Posts: n/a
 
      10-10-2005
Who decides size of data types in C?
Is it the:
1.C standard and hence the compilers
2.Operating System.

 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      10-10-2005
In article <(E-Mail Removed). com>,
siliconwafer <(E-Mail Removed)> wrote:

>Who decides size of data types in C?
>Is it the:
>1.C standard and hence the compilers
>2.Operating System.


Both, or rather all three.

The standard places constraints on the minimum size of several types.
The compiler can use any sizes it likes that meet these constraints,
but in order to interoperate with the operating system's libraries and
meet the expectations of users any successful compiler will have to
take the operating system into account.

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

-- Richard
 
Reply With Quote
 
 
 
 
7trackers@gmail.com
Guest
Posts: n/a
 
      10-10-2005
what about the Hardware...Doesn't it maily rely on that...?

coz if the H/w is capable then only...the implementation is useful...?

right..?

 
Reply With Quote
 
siliconwafer
Guest
Posts: n/a
 
      10-10-2005

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> what about the Hardware...Doesn't it maily rely on that...?
>
> coz if the H/w is capable then only...the implementation is useful...?
>
> right..?

Which H/W *exactly* decides this?Is it the data width of memory where
the compiler stores the variables? OR is it the CPU regesters?

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      10-10-2005
(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.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Walter Roberson
Guest
Posts: n/a
 
      10-10-2005
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.)


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.
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      10-10-2005
In article <(E-Mail Removed)>,
Keith Thompson <(E-Mail Removed)> wrote:

>> 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.


Much more likely is that CHAR_BIT is 17 and pointers have 16 padding
bits

-- Richard
 
Reply With Quote
 
Netocrat
Guest
Posts: n/a
 
      10-10-2005
On Mon, 10 Oct 2005 19:43:35 +0000, Walter Roberson wrote:

> 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.


So Microsoft were right - the GPL _is_ viral!

--
http://members.dodo.com.au/~netocrat
 
Reply With Quote
 
siliconwafer
Guest
Posts: n/a
 
      10-11-2005
"what about the Hardware...Doesn't it maily rely on that...? "


Which H/W *exactly* decides this?Is it the data width of memory where
the compiler stores the variables? OR is it the CPU regesters?

Reply
MyAnswer?

 
Reply With Quote
 
Walter Roberson
Guest
Posts: n/a
 
      10-11-2005
In article <(E-Mail Removed) .com>,
siliconwafer <(E-Mail Removed)> wrote:
>"what about the Hardware...Doesn't it maily rely on that...? "


>Which H/W *exactly* decides this?Is it the data width of memory where
>the compiler stores the variables? OR is it the CPU regesters?


>Reply
>MyAnswer?


Oh, I thought your question was rhetorical.

For the same hardware and the same OS, there might be several
compiler options that lead to different type sizes. Not all
of those are necessarily going to be implemented as pure hardware
operations. A 128 bit "long long" on a machine with 64 bit
registers might be processed through library calls or through
standard multi-precision techniques for simpler operations.

Integral type sizes chosen for a particular combination of
hardware + OS + compiler + flags
will -usually- involve a power-of-2 multiplied by the native
operation size, as those sizes are usualy easier to program.

Floating point type sizes, if not using the native size, are
more likely to be reliant on the politics of whatever the IEEE
committee has defined.

In any case, operation sizes supported will be strongly
influenced by marketting considerations. If your potential
customer is the National Weather Office, and they tell you
they want a 240 bit float synthesized from three 80-bit registers,
and they say, "We have $47 million for this project if you can
install 3 of them before the next hurricane season", then
you answer "Yes, certainly", not "But our longest hardware
register is only 64 bits."
--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton
 
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