Game Development Community

Mixing S32's and U32's

by Skylar Kelty · in Torque Game Engine Advanced · 08/23/2007 (11:57 am) · 2 replies

Hey, Im not too good with this but it seems to me that in version.cpp you have:

static const U32 csgVersionNumber

then

U32 getVersionNumber()

but then

ConsoleFunction( getVersionNumber, S32...

Is this right?

Should those U32's be S32's or that S32 a U32?

Like I said im not too great on Torque programming yet, its just a question ^^

#1
08/23/2007 (12:02 pm)
You will see a lot of cross-overs like this in the code, and honestly it's not a "perfect world" design scenario, but the root reason is this:

Many times in design, it's better to treat a value as if it is unsigned (U32), and use "zero" as meaning it hasn't been set.

However, in implementation/use of the design, it can be important to have the ability to use the sign of a return result (most commonly -1) to indicate a "negative response"--for example, if you want to check the ID of an object in the simulation, the value will always be positive if the object is in the simulation--but in use, it's very convenient to return "-1" if the object doesn't exist in the simulation. This use technique of course requires the return value to be signed (S32).
#2
08/24/2007 (12:26 am)
Thanks for the clarification