Difference between revisions of "Longint"

From Free Pascal wiki
Jump to navigationJump to search
(Expanded page with translated content from German page)
Line 1: Line 1:
 
{{Longint}}
 
{{Longint}}
  
A '''longint''' is an signed [[Integer|integer]] in the range of -2 147 483 648 ... 2 147 483 647  (-2,147,483,648 ... 2,147,483,647), or -2<sup>31</sup> ... 2<sup>31</sup>-1.
+
 
The longint is 4 bytes ([[32 bit]]) long. The [[Cardinal]] type is 32 bits long, too. But the Cardinal [[Data_type|data type]] is an unsigned type.
+
Back to [[Data type|data types]].
 +
 
 +
 
 +
Range of values: -2,147,483,648 .. 2,147,483,647 (-2<sup>31</sup> .. 2<sup>31</sup>-1)
 +
 
 +
Memory requirement: 4 bytes or 32 bits (The [[Cardinal]] type is also 32 bits long, but is an unsigned type.)
 +
 
 +
A data field of the '''LongInt''' data type can only take integer values ​​with and without sign.
 +
Assigning other values ​​leads to compiler error messages when the program is compiled and the compilation process is aborted. That is, the executable program is not created.
 +
 
 +
Definition of a Longint data field:
 +
 
 +
<syntaxhighlight lang=pascal>
 +
  var
 +
    left : Longint;
 +
</syntaxhighlight>
 +
 
 +
Examples of assigning valid values:
 +
 
 +
<syntaxhighlight lang=pascal>
 +
  left := -2147483648;
 +
  left := 0;
 +
  left := 2147483647;
 +
</syntaxhighlight>
 +
 
 +
Examples of assigning invalid values:
 +
 
 +
<syntaxhighlight lang=pascal>
 +
  left := '-2147483648';
 +
  left := '0';
 +
  left := '2147483647';
 +
</syntaxhighlight>
 +
 
 +
The difference between the two examples is that the upper example is the assignment of literals of the type integer, while the assignment of the lower example is literals of the type String.
 +
 
  
 
{{Data types}}
 
{{Data types}}

Revision as of 06:33, 19 February 2020

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


Back to data types.


Range of values: -2,147,483,648 .. 2,147,483,647 (-231 .. 231-1)

Memory requirement: 4 bytes or 32 bits (The Cardinal type is also 32 bits long, but is an unsigned type.)

A data field of the LongInt data type can only take integer values ​​with and without sign. Assigning other values ​​leads to compiler error messages when the program is compiled and the compilation process is aborted. That is, the executable program is not created.

Definition of a Longint data field:

  var 
    left : Longint;

Examples of assigning valid values:

  left := -2147483648;
  left := 0;
  left := 2147483647;

Examples of assigning invalid values:

  left := '-2147483648';
  left := '0';
  left := '2147483647';

The difference between the two examples is that the upper example is the assignment of literals of the type integer, while the assignment of the lower example is literals of the type String.



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