[comp.lang.c] data types

middleto@sdsu.UUCP (Tom Middleton) (01/31/89)

Someone suggested to me that the C data types for short and long were
fixed at 16 and 32 bits respectively and that the int type size was
allowed to float based on the word size of the machine.  This seems to
fit with my experience but brings up the question.  What happens when
you go to a 48 or 64 bit machine?  Does int then become 48 or 64 bits
while long stays at 32?  And by any change was this the purpose of
creating the short and long types?  Also, is this part of the standard
or is it still under discussion?

Thanks in advance.
(it would probably be kind of you to respond via email)

-- 
 G O    P A D R E S !		Thomas Earl Middleton
    1989			aka Happy Bare
 N L    C H A M P S !		UUCP  ...!ucsd!sdsu!middleto
 W S    C H A M P S !		ARPA  middleto%sdsu.uucp@ucsd.edu

gwyn@smoke.BRL.MIL (Doug Gwyn ) (02/02/89)

In article <3447@sdsu.UUCP> middleto@sdsu.UCSD.EDU (Tom Middleton) writes:
>
>Someone suggested to me that the C data types for short and long were
>fixed at 16 and 32 bits respectively

Wrong -- those are the MINIMUM sizes for standard conformance, not the
ONLY sizes allowed.

rkl1@hound.UUCP (K.LAUX) (02/04/89)

In article <3447@sdsu.UUCP>, middleto@sdsu.UUCP (Tom Middleton) writes:
| 
| Someone suggested to me that the C data types for short and long were
| fixed at 16 and 32 bits respectively and that the int type size was
| allowed to float based on the word size of the machine.  This seems to
| fit with my experience but brings up the question.  What happens when
| you go to a 48 or 64 bit machine?  Does int then become 48 or 64 bits
| while long stays at 32?  And by any change was this the purpose of
| creating the short and long types?  Also, is this part of the standard
| or is it still under discussion?
| 

	I believe the Standard is the following:

	Int	is the default word size on the machine,
	Long	must be equal to or greater than the size of an Int,
	Short	must be equal to or less than the size of an Int.

	Therefore on a 64 bit machine:

	Int = 64 bits or 8 bytes,
	Long >= 64 bits or 8 bytes,
	Short <= 64 bits or 8 bytes.

--rkl

gwyn@smoke.BRL.MIL (Doug Gwyn ) (02/04/89)

In article <2916@hound.UUCP> rkl1@hound.UUCP (K.LAUX) writes:
>	Int	is the default word size on the machine,
>	Long	must be equal to or greater than the size of an Int,
>	Short	must be equal to or less than the size of an Int.

Close, except there is no requirement that "int" be the "natural"
word size, just a recommendation that it be so.  In fact some 64-bit
C implementors have had to agonize over whether to make int 64 bits
or 32.  (The latter to make it easier to port 4BSD VAX code that has
that assumption, or the assumption that long is 32 bits, wired in.)

middleto@sdsu.UUCP (Tom Middleton) (02/05/89)

In article <2916@hound.UUCP> rkl1@hound.UUCP (K.LAUX) writes:
>	Int	is the default word size on the machine,
>	Long	must be equal to or greater than the size of an Int,
>	Short	must be equal to or less than the size of an Int.

In article <> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
-Close, except there is no requirement that "int" be the "natural"
-word size, just a recommendation that it be so.  In fact some 64-bit
-C implementors have had to agonize over whether to make int 64 bits
-or 32.  (The latter to make it easier to port 4BSD VAX code that has
-that assumption, or the assumption that long is 32 bits, wired in.)

Yes, sizeof(int) on our 64-bit machine returned 4 (4*8=32) so the
compiler writers decided to stick with a 32-bit int, even tho the
word size is 64.

The general consensus is
	sizeof(short) <= sizeof(int) <= sizeof(long)
Thank you to all the people who have responded.

Now, please, I ask you in the most respectful manner, stop, no more, this
question is resolved.  Thank you.

-- 
 G O    P A D R E S !		Thomas Earl Middleton
    1989			aka Happy Bare
 N L    C H A M P S !		UUCP  ...!ucsd!sdsu!middleto
 W S    C H A M P S !		ARPA  middleto%sdsu.uucp@ucsd.edu