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 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.
|Name||Size||Min (dec)||Max (dec)|
|unsigned char/byte||8 bits||0||255|
|unsigned short||16 bits||0||65.535|
|unsigned int||32 bits||0||4.294.967.295|
|long/long long||64 bits||-9,223,372,036,854,775,808||9,223,372,036,854,775,807|
|unsigned long/long long||64 bits||0||18.446.744.073.709.551.615|
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.
|bool/boolean||8 bits||false (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).
|Name||Size||depricated||Max abs.||Min abs. w/o 0|
|Extended Precision||80 bits (x86)||no||1.18e4932||3.65e−4951|
|decimal (C#)||128 bits||no||7.92e28||1e-28|
This table only covers the most significant float types regarding understanding, game hacking and basic programming. Many more exist.