473,767 Members | 1,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Size of int

Hi,

It is said that the size of short,int,long, float and double depends on
the machine whereas the size of char is 1-byte.
Now, what do they mean by the size depends on the machine? I mean if i
have a 32-bit machine, then what will be the size of int?

Thanks.

Jun 12 '07 #1
5 39243
Nikhil Bokare <nb*****@gmail. comwrites:
It is said that the size of short,int,long, float and double depends on
the machine whereas the size of char is 1-byte.
Now, what do they mean by the size depends on the machine? I mean if i
have a 32-bit machine, then what will be the size of int?
The sizes of the predefined integer types depend on the compiler. The
decision of the compiler's author is likely to be guided by the
characteristics of the machine, but there can be other considerations
as well, such as compatibility with other systems.

On a 32-bit machine, the size of int will be (a) sizeof(int), by
definition, (b) whatever size the compiler writers chose, (c) *likely*
to be 32 bits, but this isn't guaranteed by the language.

See section 1 of the comp.lang.c FAQ, <http://www.c-faq.com/>.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 12 '07 #2
On Jun 12, 3:10 pm, Keith Thompson <k...@mib.orgwr ote:
Nikhil Bokare <nbok...@gmail. comwrites:
It is said that the size of short,int,long, float and double depends on
the machine whereas the size of char is 1-byte.
Now, what do they mean by the size depends on the machine? I mean if i
have a 32-bit machine, then what will be the size of int?

The sizes of the predefined integer types depend on the compiler. The
decision of the compiler's author is likely to be guided by the
characteristics of the machine, but there can be other considerations
as well, such as compatibility with other systems.

On a 32-bit machine, the size of int will be (a) sizeof(int), by
definition, (b) whatever size the compiler writers chose, (c) *likely*
to be 32 bits, but this isn't guaranteed by the language.
And (d) large enough to hold a value of INT_MAX
See section 1 of the comp.lang.c FAQ, <http://www.c-faq.com/>.


Jun 12 '07 #3
Lew Pitcher <lp******@teksa vvy.comwrites:
On Jun 12, 3:10 pm, Keith Thompson <k...@mib.orgwr ote:
[...]
>On a 32-bit machine, the size of int will be (a) sizeof(int), by
definition, (b) whatever size the compiler writers chose, (c) *likely*
to be 32 bits, but this isn't guaranteed by the language.

And (d) large enough to hold a value of INT_MAX
Which is guaranteed to be at least 32767.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 12 '07 #4
Nikhil Bokare wrote, On 12/06/07 19:22:
Hi,

It is said that the size of short,int,long, float and double depends on
the machine whereas the size of char is 1-byte.
Now, what do they mean by the size depends on the machine?
Exactly what it says. Actually, it depends on the implementation since
sometimes there are different compilers (or the same compiler with
different options) where the size of some of these things are different.
I mean if i
have a 32-bit machine, then what will be the size of int?
That depends on what you mean by a 32 bit machine and the size of a
byte. This is not just quibbling, I've used processors with 16 bit
bytes, others here have used processors with 32 bit bytes. So a 32 bit
int could be as small as 1 byte or as large as 4 (assuming no padding).
Or you could have a 32 bit processor but a compiler which provides a 16
bit int, and yes this does happen.
--
Flash Gordon
Jun 12 '07 #5
Flash Gordon wrote:
>
Nikhil Bokare wrote, On 12/06/07 19:22:
[...]
I mean if i
have a 32-bit machine, then what will be the size of int?

That depends on what you mean by a 32 bit machine and the size of a
byte. This is not just quibbling, I've used processors with 16 bit
bytes, others here have used processors with 32 bit bytes.
And, on these systems, it's possible that chars were 16 or 32 bits,
yet sizeof(char) is still, by definition, one.
So a 32 bit
int could be as small as 1 byte or as large as 4 (assuming no padding).
Or you could have a 32 bit processor but a compiler which provides a 16
bit int, and yes this does happen.
And, nowadays, a "64 bit processor" with a 32-bit int. (Or even a
16-bit int, though this is not likely if using a "modern" compiler
targeted to that platform.)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com>

Jun 13 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7108
by: Marti | last post by:
Dear everyone, Its my understanding that IE6 now uses a default text-size of "Small" rather than IE5's "Medium". Since I have used relative font-sizes (usually in ems) on all my sites, I am now getting reports of "your fonts are too tiny" from various users. Of course, the sites still look fine if those users set their text-size to medium, but face it -- most people don't even know thats an option.
25
7593
by: Matthias | last post by:
Hi, I am just reading that book by Scott Meyers. In Item 4 Meyers suggests to always use empty() instead of size() when probing for emptyness of STL containers. His reasoning is that size() might take linear time on some list implementations. That makes sense at first. However, he also says this at the very beginning: "That being the case , you might wonder why one construct should be preferred to the other, especially in view of the...
9
3778
by: Dr John Stockton | last post by:
Assuming default set-ups and considering all reasonable browsers, whatever that may mean, what should an author expect that his readers in general will see (with visual browsers) for a page with body like <br><br> Abc <font size=+1> Abc <font size=+1> Abc <font size=+1> Abc <font size=+1> Abc <font size=+1>
2
28599
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
4
3496
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a snippet from my .css file: *************************** body { margin:0; padding:0;
27
31433
by: Deephay | last post by:
Greetings all, I have a program that used the realloc() function to change the allocated size of a buffer, the program works with some arguments, but with some other arguments, it will show me the error message like: *** glibc detected *** realloc(): invalid next size: 0x0804c3a8 *** and then I inserted a perror("realloc") to see what happend, it says that:
8
10167
by: redefined.horizons | last post by:
I would like to have an array declaration where the size of the array is dependent on a variable. Something like this: /* Store the desired size of the array in a variable named "array_size". */ unsigned short int array_size = 25; /*Declare an array named "numbers" using the variable initialized above. */ unsigned short int numbers;
7
43930
by: carterweb | last post by:
This is how I do it now. 1. Determine the dimensions of the rectangle. 2. Set a my font size to a fixed maximum size. 3. Apply the font my string and measure the string using the graphics object. 4. If string size is less than the size of the rectangle, we are done.
18
25004
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin, that IE7 does not seem to offer any way to control the font size of a text input element.
27
3241
by: 1001 Webs | last post by:
I am trying to make my style sheet as compatible as possible and I'm getting a bit confused here. I've read that the best size for font-size would be 76.1%; due to shortcomings in the way both IE and Opera render that attribute. Is this correct?
0
9405
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10013
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9960
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8838
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7383
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3930
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.