Primitive Datatypes

In computing primitive datatypes make the base of all more complex data structures. Each of them does nothing more than storing numbers. They just differ by size and interpretation.
The size is highly dependant by the type. The maximung lenght of a primitive type is limited by the hardware. For instance, an 8-bit machine may only operate with numbers that do not exceed 8 bits in length. Exceptions may apply such as the RP2A03 processor used as central processing unit in the NES which is able to exceed this limit in address handling.
Modern systems are based on a 64-bit architecture and can handle huge numbers in general. But since we are interested in hacking games of any generation it is meaningful being aware of all primitive datatypes and their limits!

Integers

Integers describe either positive or negative natural numbers with no fraction. There's two types of integers: Signed and unsigned integers. By default integers are signed meaning their range is half negative and have positive including 0.
Unsigned integers only can be positive but can be twice as big as their signed counterpart.

The table below represents all common integer types.

NameSizeMin (dec)Max (dec)
char/byte8 bits-128127
unsigned char/byte8 bits0255
short16 bits–32.76832.767
unsigned short16 bits065.535
int32 bits-2,147,483,6482,147,483,647
unsigned int32 bits04.294.967.295
long/long long64 bits-9,223,372,036,854,775,8089,223,372,036,854,775,807
unsigned long/long long64 bits018.446.744.073.709.551.615

Booleans

A boolean value only knows two states: true or false. False can be seen as a representation of 0 or off and true as 1 or on. One might think since only 2 values are possible a boolean may only occupy one bit in memory, but infact, it occupies an entire byte (8 bits) since 1 byte is the smallest addressable value. But it is still possible to store 8 booleans withing a single byte. One bit's state can be checked with boolean operators such as AND or OR. This mechanism is called a DIP Switch. The entire concept of DIP Switches will be explained separately.

NameSizeMinMax
bool/boolean8 bitsfalse (0)true (1)

Floating Point Numbers

Floating point numbers are used to represent numbers with a fraction. In computing this is done via a floating point arithmetic. A floating point value consists of mantissa, exponent and the sign bit. In modern computing highly precise floating point types are used. Smaller/less precise formats are less commonly used, moslty for educational porpuses. Since all floats have a sign flag, all types of floats can also be negative. Value like -0 (minus zero) and -Infinite (minus infinite) exist as well. A small range is not usable and defined as NaN (not a number).

NameSizedepricatedMax abs.Min abs. w/o 0
mini8 bitsyes153600.125
mini/half/bitfloat1616 bitsyes65,5040.0000000596
float/single/decimal3232 bitsno3.4e381.40e-45
double/decimal6464 bitsno1.797e3084.941e-324
Extended Precision80 bits (x86)no1.18e49323.65e−4951
decimal (C#)128 bitsno7.92e281e-28

This table only covers the most significant float types regarding understanding, game hacking and basic programming. Many more exist.

References

©Lawn Meower (Sophie Schmidt) 2015 - 2024