Difference between revisions of "Word"

From Lazarus wiki
m (Fixed syntax highlighting)
Line 1: Line 1:
 +
{{Word}}
 +
 +
 +
Back to [[Data type|data types]].
  
{{Word}}
 
  
 
A Word is a 16 bits unsigned [[Integer|integer]] value. It requires two bytes of memory space. Its maximal value is 65,535 ((2^16 - 1) or [[Hexadecimal|hexadecimal]] [[Dollar_sign|$]]FFFF (or 0xFFFF) and its minimal value is 0.
 
A Word is a 16 bits unsigned [[Integer|integer]] value. It requires two bytes of memory space. Its maximal value is 65,535 ((2^16 - 1) or [[Hexadecimal|hexadecimal]] [[Dollar_sign|$]]FFFF (or 0xFFFF) and its minimal value is 0.
Line 6: Line 9:
 
Nowadays Words are rarely used in arithmetic operations (because most of the CPU have some [[32 bit]] registers, if not [[64 bit]]), but they can be encountered in some API to encode some flags with logical operations (like in a [[Set|set]]).
 
Nowadays Words are rarely used in arithmetic operations (because most of the CPU have some [[32 bit]] registers, if not [[64 bit]]), but they can be encountered in some API to encode some flags with logical operations (like in a [[Set|set]]).
 
And some [[Embedded|embedded]] systems.
 
And some [[Embedded|embedded]] systems.
 
  
 
A simple program using a word [[Type|type]] [[Variable|variables]]:
 
A simple program using a word [[Type|type]] [[Variable|variables]]:
  
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
  
 
program wordexam;
 
program wordexam;

Revision as of 11:19, 4 March 2020

Deutsch (de) English (en) suomi (fi) français (fr) русский (ru)


Back to data types.


A Word is a 16 bits unsigned integer value. It requires two bytes of memory space. Its maximal value is 65,535 ((2^16 - 1) or hexadecimal $FFFF (or 0xFFFF) and its minimal value is 0.

Nowadays Words are rarely used in arithmetic operations (because most of the CPU have some 32 bit registers, if not 64 bit), but they can be encountered in some API to encode some flags with logical operations (like in a set). And some embedded systems.

A simple program using a word type variables:

program wordexam;

var
  w1,w2: word;

begin
  w1 := 1;
  w2 := $2ef;
  writeln ( w1,'+', w2,' = ' , w1+w2);
end.


navigation bar: data types
simple data types

boolean byte cardinal char currency double dword extended int8 int16 int32 int64 integer longint real shortint single smallint pointer qword word

complex data types

array class object record set string shortstring