Re: [GD-General] meaning of sizeof(int) on all plateform
Brought to you by:
vexxed72
|
From: <Lag...@wa...> - 2003-06-26 20:14:39
|
Messageno confusion here,=20
Following suestion here are purelly curiosity:
i precise the question:
if you have a 32 bit architecture (pentium)
if you want make fast arithmetic operation, you
must work with type which have a size of 32bits.
These type have the same size of a register and the
arithmetic operation can be optimize...
typically, this is type "int"
on a 64 bit architecture (itanium)=20
register are 64 bit and int are 64bit too
so if you have a program which perform the following code:
// imaginary define
// the goal of this define is to have s32 on 32bits
#ifdef __32Bit__
typedef int s32
#else // __64bit__
typedef short u32 // just for exemple
#endif
void add(s32 a1, s32 a2)
{
return a1 + a2;
}
the performance can be poor on a 64bit architecture because we are not
in the native size of the register
if we have this code
void add(int a1, int a2)
{
return a1 + a2;
}
no problem, cause "int" is native to the architecture
it is my imagination, I'am in the wrong way ?
another question, is sizeof(int) =3D=3D sizeof(void*) ?
sizeof(void*) must be : size of memory bus address
so sizeof(int)....
--------------------------
Lagarde S=E9bsatien
Neko entertainment
Junior programmer
----- Original Message -----=20
From: Mick West=20
To: gam...@li...=20
Sent: Thursday, June 26, 2003 8:48 PM
Subject: RE: [GD-General] meaning of sizeof(int) on all plateform
128 bits would give you 16 bytes, not 32.
On the PS2 an int is generally 32 BITS, (4 bytes), which is maybe =
where the confusion arose.
Mick
-----Original Message-----
From: gam...@li... =
[mailto:gam...@li...] On Behalf Of =
Gareth Lewin
Sent: Thursday, June 26, 2003 11:42 AM
To: gam...@li...
Subject: RE: [GD-General] meaning of sizeof(int) on all plateform
sizeof(int) =3D size of integer value. As defined by the compiler =
vendor. There is no "Correct" way to set the size of int.
-----Original Message-----
From: Lagarde S=E9bastien [mailto:Lag...@wa...]
Sent: 26 June 2003 19:36
To: gam...@li...
Subject: [GD-General] meaning of sizeof(int) on all plateform
Hello all,=20
I have some problem to define what represent sizeof(int).
IMO sizeof(int) =3D=3D memory bus address width
but on platforme like PS2, you have a bus of 128 and sizeof(int) =
=3D=3D 32.
i have seen elsewherre that sizeof(int) =3D=3D size of a register.
Is someone have some information on this point ?
thanks
-------------------------------
Lagarde S=E9bastien
Neko entertainment
Junior programmer
|