Data Types: Difference between revisions
From RuneWiki
(Created page with "== Types == Byte Word SWord DWord QWord String === Transformations === Add Subtract Negate Reverse === Endianness === Big Little Middle-Big Middle-Little === Spe...") |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Types == | ==Types== | ||
Byte | {| class="wikitable" | ||
!Name | |||
!Length | |||
!Notes | |||
|- | |||
|Byte | |||
|1 | |||
|<nowiki>0 to 255 unsigned | -128 to +127 signed</nowiki> | |||
|- | |||
|Word | |||
|2 | |||
|<nowiki>0 to 65,535 unsigned | -32,768 to +32,767 signed</nowiki> | |||
|- | |||
|SWord* | |||
|3 | |||
|<nowiki>0 to 16,777,215 unsigned | −8,388,608 to 8,388,607 signed</nowiki> | |||
|- | |||
|DWord | |||
|4 | |||
|<nowiki>0 to 4,294,967,295 unsigned | -2,147,483,648 to 2,147,483,647 signed</nowiki> | |||
|- | |||
|QWord | |||
|8 | |||
|<nowiki>0 to 18,446,744,073,709,551,615 unsigned | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 signed</nowiki> | |||
|- | |||
|String | |||
|1+ | |||
|Newline-terminated, not null-terminated like C | |||
|} | |||
<nowiki>*</nowiki>SWord means sesqui word, or one and a half words. | |||
Word | ==Special Types== | ||
{| class="wikitable" | |||
!Name | |||
!Base | |||
!Notes | |||
|- | |||
|Base37 | |||
|QWord | |||
|Base37 hash of a string | |||
|- | |||
|Interface Color | |||
|Word | |||
|5-bits per channel | |||
|- | |||
|Model Color | |||
|Word | |||
| | |||
|- | |||
|Smart | |||
|Byte/Word | |||
|1 or 2 byte value (-16384 to +16383) | |||
|- | |||
|Unsigned Smart | |||
|Byte/Word | |||
|1 or 2 byte value (0 to 32768) | |||
|} | |||
==Byte Transformations== | |||
These transformations only apply to the least significant byte, regardless of the endianness. | |||
{| class="wikitable" | |||
!Name | |||
!Operation | |||
|- | |||
|Add | |||
|byte + 128 | |||
|- | |||
|Subtract | |||
|128 - byte | |||
|- | |||
|Negate | |||
| -byte | |||
|} | |||
==Byte Order== | |||
Also known as Endianness. | |||
{| class="wikitable" | |||
!Name | |||
!Order | |||
|- | |||
== | |Big | ||
|4, 3, 2, 1 | |||
|- | |||
|Little | |||
|1, 2, 3, 4 | |||
|- | |||
|Middle | |||
|3, 4, 1, 2 | |||
|- | |||
|Reversed Middle | |||
|2, 1, 4, 3 | |||
|} | |||
Little | Middle endianness only applies to DWords. | ||
Middle | |||
Revision as of 23:24, 6 September 2021
Types
Name | Length | Notes |
---|---|---|
Byte | 1 | 0 to 255 unsigned | -128 to +127 signed |
Word | 2 | 0 to 65,535 unsigned | -32,768 to +32,767 signed |
SWord* | 3 | 0 to 16,777,215 unsigned | −8,388,608 to 8,388,607 signed |
DWord | 4 | 0 to 4,294,967,295 unsigned | -2,147,483,648 to 2,147,483,647 signed |
QWord | 8 | 0 to 18,446,744,073,709,551,615 unsigned | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 signed |
String | 1+ | Newline-terminated, not null-terminated like C |
*SWord means sesqui word, or one and a half words.
Special Types
Name | Base | Notes |
---|---|---|
Base37 | QWord | Base37 hash of a string |
Interface Color | Word | 5-bits per channel |
Model Color | Word | |
Smart | Byte/Word | 1 or 2 byte value (-16384 to +16383) |
Unsigned Smart | Byte/Word | 1 or 2 byte value (0 to 32768) |
Byte Transformations
These transformations only apply to the least significant byte, regardless of the endianness.
Name | Operation |
---|---|
Add | byte + 128 |
Subtract | 128 - byte |
Negate | -byte |
Byte Order
Also known as Endianness.
Name | Order |
---|---|
Big | 4, 3, 2, 1 |
Little | 1, 2, 3, 4 |
Middle | 3, 4, 1, 2 |
Reversed Middle | 2, 1, 4, 3 |
Middle endianness only applies to DWords.