On Friday 30 September 2005 06:07, [EMAIL PROTECTED] wrote:
> > So what is the reasoning why the int are still 4 bytes instead of 8 bytes
> > ?
> >
> > Can anyone clarify ?
>
> There are a whole bunch of things in programs where a 32 bit integer
> is sufficient and 64 bits is complete overkill. The first example that
> comes to mind is counters used in for loops, or array indexing. For
> most of these cases, using a 32 bit integer will be faster than using
> a 64 bit integer (mainly because of memory bandwidth when the register
> is loaded from or stored to dram).
>
> In addition, C is used for low level programming where the programmer
> needs to be able to address 32 bit hardware registers. If int was
> 32 bits, what would you use for accessing these registers.

Everyone is missing the most important point!!! sizeof (int) is a compiler 
issue NOT a harware issue. It does not make good sense, but you can have 64 
bit ints on a Z80 (old 8 bit processor) or 16 bit ints on a 64 bit machine.

Having ints the same size as the hardware is a GoodThing (tm).

tick-tock-tick-tock-bing! 64 bit ints are touted as being an easier fix than 
re-org'ing the epoch, so 64bit ints WILL happen and 64bit machines are better 
equipped to handle this

   Explains: in 2039 the clock (32 bit) will overflow. This is Y2K bug with a 
             vengance and a certainty.

Will 64 bit ints waste the cache. This is deep dark art, but I believe NOT:
cache is for speed. speed = 1 access to get the data so ...
c.......        a char in cache
ss......        a short in cache
iiii....        a 32int in cache
llllllll        a 64int in cache

you still use 1 cache per item, but the cache is 64bit wide

intel lets you:

[address 0] .. ii ii .. .. .. .. ..

most other architectures insist

[address 0] ii ii .. .. .. .. .. ..

or even worse

[address 0] ii ii .. .. ll ll ll ll  wasting the two .. locations. 

There are gcc options (alignment) to tell gcc to do this (much more efficient 
at cost of wasted space) but thought experiments don't work to explain if 
youc can/can't/should.

You can even have compilers that generate 32bit ints and 64bit ints on the 
same machine at the same time (carefull with the libraries)

James
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to