U32 max range is 2147483647?
by Justin Mosiman · in Torque Game Engine Advanced · 07/19/2007 (4:36 pm) · 3 replies
I don't know if this is just my machine or not, but I was playing around with the U32 type and I thought that U32 had a max value of 0xffffffff (4,294,967,295), but if I have the following code uValue gets a value of -1.
If I change uValue to 0x7fffffff (2,147,483,647) the value is fine, but changing it to 0x80000000 (2,147,483,648) causes the U32 roll over to -2,147,483,648. This is strange because U32 by definition should be unsigned. Has anybody else seen this or is it only me? I don't really need an int that large I'm just curious why this happens. Looking at types.h U32 is defined as unsigned int, so that is right, but that's not what I'm getting.
U32 uValue= 0xffffffff;
If I change uValue to 0x7fffffff (2,147,483,647) the value is fine, but changing it to 0x80000000 (2,147,483,648) causes the U32 roll over to -2,147,483,648. This is strange because U32 by definition should be unsigned. Has anybody else seen this or is it only me? I don't really need an int that large I'm just curious why this happens. Looking at types.h U32 is defined as unsigned int, so that is right, but that's not what I'm getting.
Torque 3D Owner Tom Bampton
T.