Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Size of data types
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chiru Reddy  
View profile  
 More options Nov 2 2011, 1:50 pm
Newsgroups: comp.lang.c.moderated
From: Chiru Reddy <chiru.0123456...@gmail.com>
Date: Wed, 2 Nov 2011 12:50:27 -0500 (CDT)
Local: Wed, Nov 2 2011 1:50 pm
Subject: Size of data types
what will be the size of data types(long, int, char, short) on a 64-
bit architecture?
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Kuyper  
View profile  
 More options Nov 3 2011, 11:23 pm
Newsgroups: comp.lang.c.moderated
From: James Kuyper <jameskuy...@verizon.net>
Date: Thu, 3 Nov 2011 22:23:49 -0500 (CDT)
Local: Thurs, Nov 3 2011 11:23 pm
Subject: Re: Size of data types
On 11/02/2011 01:50 PM, Chiru Reddy wrote:

> what will be the size of data types(long, int, char, short) on a 64-
> bit architecture?

Whatever the implementation wants them to be, which will be different
for different implementations of C.
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hans-Bernhard Bröker  
View profile  
 More options Nov 3 2011, 11:24 pm
Newsgroups: comp.lang.c.moderated
From: Hans-Bernhard Bröker <HBBroe...@t-online.de>
Date: Thu, 3 Nov 2011 22:24:19 -0500 (CDT)
Local: Thurs, Nov 3 2011 11:24 pm
Subject: Re: Size of data types
On 02.11.2011 18:50, Chiru Reddy wrote:

> what will be the size of data types(long, int, char, short) on a 64-
> bit architecture?

Whatever the implementor decides to make them --- within the limitations
set by the standard, hopefully.
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Damon  
View profile  
 More options Nov 3 2011, 11:24 pm
Newsgroups: comp.lang.c.moderated
From: Richard Damon <news.x.richardda...@xoxy.net>
Date: Thu, 3 Nov 2011 22:24:34 -0500 (CDT)
Local: Thurs, Nov 3 2011 11:24 pm
Subject: Re: Size of data types
On 11/2/11 1:50 PM, Chiru Reddy wrote:

> what will be the size of data types(long, int, char, short) on a 64-
> bit architecture?

It really depends on what the implementation decides.

It if very likely that char will be 8, and short 16 bits.

int, while it legally could be 16 bits is actually probably 32 or 64
bits. The 32 bit choice has the advantages that it hides many porting
problems from programmers on 32 bit machines just assuming int is 32
bits. It also provides a "standard" type for 32 bits.

int could also be 64 bits, to meet the intent of the standard for int to
be the "natural" size of the processor, but this then says that a 32 bit
type must be an "extended integer type" which is a concept many
programmers aren't comfortable with.

long is probably 64 bits, but if int is 32 bits, it might also be 32
bits for backwards compatibility. If int is 64 bits, there may be some
reasoning that long should then be 128 bits, for people used to long
being bigger than int, but most of that has been stamped out by the
prevalence of 32 bit machines with both 32 bit int and long.

long long is probably a 128 bit type (unless long is, then it is likely
256 bits).
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Richter  
View profile  
 More options Nov 3 2011, 11:24 pm
Newsgroups: comp.lang.c.moderated
From: Thomas Richter <t...@math.tu-berlin.de>
Date: Thu, 3 Nov 2011 22:24:49 -0500 (CDT)
Local: Thurs, Nov 3 2011 11:24 pm
Subject: Re: Size of data types
On 02.11.2011 18:50, Chiru Reddy wrote:

> what will be the size of data types(long, int, char, short) on a 64-
> bit architecture?

Whatever the compiler chooses it to be.

For GNU, sizeof(char) = 1 (as always and mandated by the standard),
sizeof(short) = 2, sizeof(int) = 4, sizeof(long) = 8, sizeof(long long) = 8.

For VS, sizeof(char) = 1, sizeof(short) = 2, sizeof(int) = 4,
sizeof(long) = 4, sizeof(long long) = 8.
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dag-Erling Smørgrav  
View profile  
 More options Nov 3 2011, 11:25 pm
Newsgroups: comp.lang.c.moderated
From: Dag-Erling Smørgrav <d...@des.no>
Date: Thu, 3 Nov 2011 22:25:04 -0500 (CDT)
Local: Thurs, Nov 3 2011 11:25 pm
Subject: Re: Size of data types

Chiru Reddy <chiru.0123456...@gmail.com> writes:
> what will be the size of data types(long, int, char, short) on a 64-
> bit architecture?

It depends.  Here is a partial list for FreeBSD/amd64, which is fairly
typical:

byte order       1234
char is          signed

type                 size    alignment
--------------------------------------
char                    8            8
short                  16           16
int                    32           32
long                   64           64
long long              64           64
intmax_t               64           64
float                  32           32
double                 64           64
long double           128          128
size_t                 64           64
ptrdiff_t              64           64
time_t                 64           64
void_ptr               64           64
func_ptr               64           64
wchar_t                32           32
sig_atomic_t           64           64

This model is commonly known as I32LP64.  Linux/x86_64 is similar
except that sig_atomic_t is 32 bits wide.  I haven't tested any other
operating systems.

You can get the source code for the program that generated this list
from <URL:http://svn.freebsd.org/base/user/des/sizes/sizes.c>; it should
compile cleanly on any hosted C99 implementation.  Note that this does
*not* include Microsoft's C compiler, which only implements C89.

DES
--
Dag-Erling Smørgrav - d...@des.no
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gordon Burditt  
View profile  
 More options Nov 3 2011, 11:25 pm
Newsgroups: comp.lang.c.moderated
From: gordonb.t0...@burditt.org (Gordon Burditt)
Date: Thu, 3 Nov 2011 22:25:19 -0500 (CDT)
Local: Thurs, Nov 3 2011 11:25 pm
Subject: Re: Size of data types

> what will be the size of data types(long, int, char, short) on a 64-
> bit architecture?

That is insufficient information.  "64 bit" may refer to the size of
a *pointer*, not that of an integer.  If the architecture had a 32-bit
history, that may affect the design to make upgrading easy.

        Mimimum size (pick largest)        Maximum size (pick smallest)

char    8 bits                             size of short
Since Unicode fits in 32 bits without multibyte encoding, it is
unlikely a char is larger than 32 bits.
Lots of stuff will break if char is larger than 8 bits.

short   16 bits                            size of int
        size of char
A lot of networking stuff depends on the existence of a 16-bit type.
(which could be int16_t).

int     16 bits                            size of long
        size of short
int is likely at least 32 bits in any architecture bigger than an Intel 386.

long    32 bits                            size of long long
        size of int
If it's a "64-bit architecture", long is probably at least 64 bits.

long long 64 bits                           unlimited
        size of long                        probably not more than 128 bits

You might have:
        char/short/int/long/long long
        8   / 16  / 32 / 64 / 64 or
        8   / 16  / 32 / 64 / 128 or
        8   / 16  / 64 / 64 / 128 or
        8   / 16  / 32 / 32 / 64

Possible, but much less likely (except maybe in digital signal processor
chips), are:
        32  / 32  / 32 / 64 / 64
        64  / 64  / 64 / 64 / 64
        64  / 64  / 64 / 64 / 128
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Schwarz  
View profile  
 More options Nov 3 2011, 11:25 pm
Newsgroups: comp.lang.c.moderated
From: Barry Schwarz <schwa...@dqel.com>
Date: Thu, 3 Nov 2011 22:25:34 -0500 (CDT)
Local: Thurs, Nov 3 2011 11:25 pm
Subject: Re: Size of data types
On Wed, 2 Nov 2011 12:50:27 -0500 (CDT), Chiru Reddy

<chiru.0123456...@gmail.com> wrote:
>what will be the size of data types(long, int, char, short) on a 64-
>bit architecture?

Whatever the designer of your particular implementation decided they
should be.  On many 64-bit hardware systems (architecture), it is
still possible to install a 32-bit implementation (compiler, linker,
and run-time library) and use it as it was intended.

sizeof(char) is always 1 by definition and the number of bits in that
one "byte" is documented in the CHAR_BITS macro.  If you need to know
the size of an int, use the expression sizeof(int) and the compiler
will figure it out for you.  In fact, using this expression will allow
simplify making your code portable between implementations with
different int sizes (giving it to someone else, upgrading your
compiler, etc).

You can get a lower bound (in terms of number of bits) on the size of
an int by looking at the INT_MAX macro.

--
Remove del for email
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fasked  
View profile  
 More options Nov 3 2011, 11:25 pm
Newsgroups: comp.lang.c.moderated
From: fasked <fas...@gmail.com>
Date: Thu, 3 Nov 2011 22:25:49 -0500 (CDT)
Local: Thurs, Nov 3 2011 11:25 pm
Subject: Re: Size of data types
On Nov 2, 9:50 pm, Chiru Reddy <chiru.0123456...@gmail.com> wrote:
> what will be the size of data types(long, int, char, short) on a 64-
> bit architecture?

See the `limits.h' header file. Usually there are following values:
char - 1 byte, short - 2 bytes, int - 4 bytes, long - 8 bytes.
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Keith Thompson  
View profile  
 More options Nov 4 2011, 3:51 am
Newsgroups: comp.lang.c.moderated
From: Keith Thompson <ks...@mib.org>
Date: Fri, 4 Nov 2011 02:51:55 -0500 (CDT)
Local: Fri, Nov 4 2011 3:51 am
Subject: Re: Size of data types
Barry Schwarz <schwa...@dqel.com> writes:

[...]
> sizeof(char) is always 1 by definition and the number of bits in that
> one "byte" is documented in the CHAR_BITS macro.

[...]

CHAR_BIT, not CHAR_BITS.

--
Keith Thompson (The_Other_Keith) ks...@mib.org  <http://www.ghoti.net/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincenzo Mercuri  
View profile  
 More options Nov 28 2011, 10:01 pm
Newsgroups: comp.lang.c.moderated
From: Vincenzo Mercuri <vincenzo.merc...@yahoo.it>
Date: Mon, 28 Nov 2011 21:01:59 -0600 (CST)
Local: Mon, Nov 28 2011 10:01 pm
Subject: Re: Size of data types
Chiru Reddy ha scritto:

> what will be the size of data types(long, int, char, short) on a 64-
> bit architecture?

Of course it depends on the implementation, within the
limitations demanded by the standard, as you have already
been told. I can just point out that there are three 64bit
programming models you need to consider: LP64, ILP64, LLP64,
where I = Int, L = Long, P = Pointer and 64 is the size in
bits of each (e.g. in LP64 the Long type and the Pointer
type are 64bits wide).

Data Type   ILP64     LLP64     LP64
======================================
  char           8         8        8
  short         16        16       16
  int           64        32       32
  long          64        32       64
  long long      -        64        -
  pointer       64        64       64

Most 64bit Unix-like OSs (included Linux, Solaris, FreeBSD/OpenBSD,
HP UX 11) have LP64 as programming model, while Windows uses the LLP64.

--
Vincenzo Mercuri | www.backbox.org
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Keith Thompson  
View profile  
 More options Nov 29 2011, 5:38 am
Newsgroups: comp.lang.c.moderated
From: Keith Thompson <ks...@mib.org>
Date: Tue, 29 Nov 2011 04:38:26 -0600 (CST)
Local: Tues, Nov 29 2011 5:38 am
Subject: Re: Size of data types

Those aren't the only possible models.  I've worked on 64-bit systems
where short is 32 bits and int, long, and long long are all 64 bits
(Cray T3E), and where all four are 64 bits (Cray T90).

--
Keith Thompson (The_Other_Keith) ks...@mib.org  <http://www.ghoti.net/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
--
comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »