Difference between revisions of "Word"
(rewrite) |
(rearrange, mention Integer, (supposedly) add new external links) |
||
Line 7: | Line 7: | ||
Most [[RTL|run-time libraries]] provide the native data type of a processor as the Pascal data type <syntaxhighlight lang="pascal" inline>word</syntaxhighlight>. | Most [[RTL|run-time libraries]] provide the native data type of a processor as the Pascal data type <syntaxhighlight lang="pascal" inline>word</syntaxhighlight>. | ||
It is a subset of all whole numbers (non-negative integers) that can be represented by the processor’s natural data unit size. | It is a subset of all whole numbers (non-negative integers) that can be represented by the processor’s natural data unit size. | ||
+ | |||
+ | On a 64-bit architecture this means a <syntaxhighlight lang="pascal" inline>word</syntaxhighlight> is an integer within the range <math>[0,~2^{64}-1]</math>. | ||
+ | On a 32-bit architecture a <syntaxhighlight lang="pascal" inline>word</syntaxhighlight> will be an integer in the range <math>[0,~2^{32}-1]</math>, and so on, respectively. | ||
In [[GNU Pascal]] a <syntaxhighlight lang="pascal" inline>word</syntaxhighlight> is just an alias for [[Cardinal|<syntaxhighlight lang="pascal" inline>cardinal</syntaxhighlight>]], which has the same properties regarding possible values. | In [[GNU Pascal]] a <syntaxhighlight lang="pascal" inline>word</syntaxhighlight> is just an alias for [[Cardinal|<syntaxhighlight lang="pascal" inline>cardinal</syntaxhighlight>]], which has the same properties regarding possible values. | ||
− | + | If a ''signed'' integer having the processor’s native size is wanted, the data type [[Integer|<syntaxhighlight lang="pascal" inline>integer</syntaxhighlight>]] provides this functionality. | |
=== FPC === | === FPC === | ||
− | Contrary to the data type’s name, in [[FPC]] a word is defined as a subrange data type <syntaxhighlight lang="pascal" inline>0..65535</syntaxhighlight>. | + | Contrary to the data type’s name, in [[FPC]] a <syntaxhighlight lang="pascal" inline>word</syntaxhighlight> is defined as a subrange data type <syntaxhighlight lang="pascal" inline>0..65535</syntaxhighlight>. |
− | <syntaxhighlight lang="pascal" inline>65535</syntaxhighlight> is <math>2^{16}-1</math>. | + | The <syntaxhighlight lang="delphi" inline>high</syntaxhighlight> value <syntaxhighlight lang="pascal" inline>65535</syntaxhighlight> is <math>2^{16}-1</math>. |
Thus a {{Doc|package=RTL|unit=system|identifier=word|text=<syntaxhighlight lang="pascal" inline>system.word</syntaxhighlight>}} occupies two bytes of space. | Thus a {{Doc|package=RTL|unit=system|identifier=word|text=<syntaxhighlight lang="pascal" inline>system.word</syntaxhighlight>}} occupies two bytes of space. | ||
Subrange data types are stored in a quantity that serves best the goals of performance and memory efficiency. | Subrange data types are stored in a quantity that serves best the goals of performance and memory efficiency. |
Revision as of 14:48, 21 May 2020
│
Deutsch (de) │
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
A word is the processor’s native data unit. Modern consumer processors have a word width of 64 bits.
Data type
Most run-time libraries provide the native data type of a processor as the Pascal data type word
.
It is a subset of all whole numbers (non-negative integers) that can be represented by the processor’s natural data unit size.
On a 64-bit architecture this means a word
is an integer within the range [math]\displaystyle{ [0,~2^{64}-1] }[/math].
On a 32-bit architecture a word
will be an integer in the range [math]\displaystyle{ [0,~2^{32}-1] }[/math], and so on, respectively.
In GNU Pascal a word
is just an alias for cardinal
, which has the same properties regarding possible values.
If a signed integer having the processor’s native size is wanted, the data type integer
provides this functionality.
FPC
Contrary to the data type’s name, in FPC a word
is defined as a subrange data type 0..65535
.
The high
value 65535
is [math]\displaystyle{ 2^{16}-1 }[/math].
Thus a system.word
occupies two bytes of space.
Subrange data types are stored in a quantity that serves best the goals of performance and memory efficiency.
This deviation from the normal usage of the term word in computer science cannot be explained.
Instead, one has to use the data type system.ptrUInt
if the processor’s native size is desired.
This data type has the same properties as a word according to the normal definition, but is more cryptic and unreadable (try pronouncing ptruint).
In FPC a smallInt
has the same size as a word
.
simple data types |
|
---|---|
complex data types |