|
-
July 2nd, 2008, 08:57 PM
#1
What determines the size of int?
The size of int changes. Sometimes it takes 16 bits in the memory (2 bytes), while in other cases it might take 32 bites (4 bytes).
I claim the compiler determines the size, but some people told me it's up to the architecture (i.e., the processor).
Am I right here?
Last edited by Talikag; July 2nd, 2008 at 09:00 PM.
-
July 2nd, 2008, 09:16 PM
#2
Re: What determines the size of int?
Technically yes the compiler determines what (machine level) instructions will be used. However it is the physical architecture that determines the optimal size for an int based on how much memory can be accessed in a single instruction.
Note that this is not walywas a multiple of 8 bits either I have worked on machines with 12 bit ints (DEC PDP), 18 bit ints (DG Nova), and 36 bit ints (IBM).
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
July 2nd, 2008, 09:25 PM
#3
Re: What determines the size of int?
Thanks for you quick post.
Just a question though, if the size of a register is 32 bits, the maximum size for an int-based intruction is 32x2 (64 bits)?
18 bits ints? really? kinda wierd. thought sizes in multiples of 4 & 8 are more accessible for the processor.
-
July 2nd, 2008, 09:54 PM
#4
Re: What determines the size of int?
 Originally Posted by Talikag
Thanks for you quick post.
Just a question though, if the size of a register is 32 bits, the maximum size for an int-based intruction is 32x2 (64 bits)?
18 bits ints? really? kinda wierd. thought sizes in multiples of 4 & 8 are more accessible for the processor.
It was only with the advent of the microprocessor that multiples of 4 became prevelant. The DEC PDP-8 used a 12 bit word, the Data General Nova an 18 bit word, and most IBM "big iron" a 36 bit word.
Even with the Intel microprocessors, the:
4004 could only address 4 bits at a time,
8008 and 8080 only 8 bits at a time
8088 had a 16 bit internal architecture but still used an 8 bit data bus.
8086 was the first to be able to address 16 bits in a single cycle.
etc....
Also consider that the processor speeds for the above mentioned machines ran from 500Khz to 4Mhz.....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
July 2nd, 2008, 10:33 PM
#5
Re: What determines the size of int?
Ok, thanks for your posts.
Tried to rate your post but apparently I have to spread some reputations around before...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|