TInt
is the natural machine word integer and
should be used in all general contexts where integer arithmetic is
desired.
TInt32
, TInt16
, and
TInt8
map onto C++ built-in types in most implementations.
These types should only be used where the size of the integer is of first
importance: sometimes, this is relevant for C++ arrays and struct/class
members. Note that C++ passes all function arguments as
TInt
, so there is nothing to be gained by using narrower
types in function interfaces.
TUint
is an unsigned integer of the natural
machine word size. Experience with C and C++ suggests that unsigned integers
are not suitable for representing quantities whose valid values should always
be positive. TInt
should be used in these circumstances
instead. The main reasons behind this surprising assertion are, firstly, that
surprises occur when C++ performs implicit type conversions for arithmetic and
assignment, and, secondly, that C++ does not trap bounds errors, with the
result that TUint
s which "accidentally" go negative
actually take on very large positive values instead.
TUint
should be used for flag and handle words,
which are manipulated using bitwise and equality-comparison operations rather
than arithmetic. TUint
should also be used in exceptional
circumstances where the full range of a machine word is required for
arithmetic: this use is exceptional and must always be carefully
controlled.
TUint32
, TUint16
, and
TUint8
types are available where the specific
representation width is important.