## FANDOM

48 Pages

In computer programming, a data type is a classification identifying one of various types of data, such as floating-point, integer, or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; and the way values of that type can be stored.

## OverviewEdit

Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology.

Common data types may include:

• booleans,
• characters,
• floating-point numbers,
• alphanumeric strings.

For example, in the Java programming language, the "int" type represents the set of 32-bit integers ranging in value from -2,147,483,648 to 2,147,483,647, as well as the operations that can be performed on integers, such as addition, subtraction, and multiplication. Colors, on the other hand, are represented by three bytes denoting the amounts each of red, green, and blue, and one string representing that color's name; allowable operations include addition and subtraction, but not multiplication.

Most programming languages also allow the programmer to define additional data types, usually by combining multiple elements of other types and defining the valid operations of the new data type. For example, a programmer might create a new data type named "complex number" that would include real and imaginary parts.

A data type also represents a constraint placed upon the interpretation of data in a type system, describing representation, interpretation and structure of values or objects stored in computer memory. The type system uses data type information to check correctness of computer programs that access or manipulate the data.

## Classes of data typesEdit

### Machine data typesEdit

All data in computers based on digital electronics is represented as bits (alternatives 0 and 1) on the lowest level. The smallest addressable unit of data is usually a group of bits called a byte (usually an octet, which is 8 bits). The unit processed by machine code instructions is called a word (as of 2011, typically 32 or 64 bits). Most instructions interpret the word as a binary number, such that a 32-bit word can represent unsigned integer values from 0 to $2^{32}-1$ or signed integer values from $-2^{31}$ to $2^{31}-1$. Because of two's complement, the machine language and machine don't need to distinguish between these unsigned and signed data types for the most part.

There is a specific set of arithmetic instructions that use a different interpretation of the bits in word as a floating-point number.

### Primitive data typesEdit

These are basic data types that are provided by the programming language with built-in support. These data types are native to the language.This data type is supported by machine directly

## Runescape Data TypesEdit

### IntroductionEdit

RuneScape uses a number of standard and non-standard data types.

### Byte OrderEdit

Data types that are two bytes or larger can be stored and ordered in a variety of different ways. Generally people either use big endian or little endian.

#### Big EndianEdit

In big endian order, the most significant byte (MSB) is stored first and the least significant byte (LSB) is stored last.

#### Little EndianEdit

In little endian order, the least significant byte (LSB) is stored first and the most significant byte (MSB) is stored last.

#### Byte order in RuneScapeEdit

RuneScape uses both little and big-endian byte orders throughout the protocol (however, the 194 client only uses big-endian order), presumably to make reverse-engineering of the protocol harder. Some confusion has arisen over the byte order as the data types are named incorrectly in Winterlove's server where little endian data types are incorrectly named as big endian types.

### Standard data typesEdit

These datatypes can also be read/written by a DataWriter/DataReader implementation (DataStreams and Buffers)

Naming conventions:

Official name Datatype name Jagex name Encoding
Byte byte 1,1b
WORD short 2,2b
DWORD int,int32 4,4b
QWORD long,int64 8,8b
C style string string,String,char *,char[] str,strbyte text bytes then '\n' or 10
Java style string string,String,char *,char[] strraw WORD length then text bytes

Note that Jagex used to use a new line character as string terminator, in more recent versions they use the null character \0 or 0 to support multi-line strings.

### Non Standard Data Types Edit

Winterlove's name Jagex name Read transformation Write transformation
Special A Unknown value - 128 value + 128
Special C Unknown 0 - value 0 - value
Special S Unknown 128 - value 128 - value
SpaceSaverA smarts (value[0] < 128) ? (((value[0] - 128)<<8)+value[1]) : value[0] if(value < 128) putword(value+32768) else putbyte(value);
SpaceSaverB smart ((value[0]<<8)+value[1]) - 49152 if(i < 64 && i >= -64) putbyte(i + 64) else if(i < 16384 && i >= -16384) putword(i + 49152);
tribyte / RGBColour / 3Byte / int3 / medium 3 (value[0] << 24) + (value[1] << 16) + value[2] putbyte(value >> 24);putbyte(value >> 16);putbyte(value);
RS_String jstr Old engine: read until newline delimiter ("\n")
New engine: read until null byte (value 0).
Old engine: write and finish with newline delimiter ("\n")
New engine: write and finish with null byte (value 0).

Additionally, RuneScape also uses two integers that are different from a big or low endian order. Both byte orders are called middle endian. Their orders could be described as following:

Middle endian big int: C3 D4 A1 B2

Middle endian small int: B2 A1 D4 C3

(A1 smallest D4 biggest byte)