Integer/fi

From Free Pascal wiki
Revision as of 14:39, 28 February 2007 by Djzepi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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

Integer kuuluu Pascal-ohjelmointikielen vakiotyyppeihin. Sitä käytetään määrittämään kokonaislukuja. Kokonaislukujen vastakohtana on reaaliluvut joissa on desimaalipiste ja mahdollisesti myös eksponentti.

Integer:n koko on riippuvainen siitä kohdekoneesta mihin kääntäjä kääntää koodin (32 bittiä tai 64 bittiä), kääntäjän tyypistä ja joissakin tapauksissa kääntäjälle annetuista ohjeista. Tyypillisiä kokoja integer:lle ovat 16 bittiä (kaksi tavua), 32 bittiä (neljä tavua) tai 64 bittiä (kahdeksan tavua).

FPC currently uses 32 bits (4 bytes) for integers, whether the machine is a 32-bit or 64-bit machine. This will cause code expecting an integer and a pointer to be the same size to fail as a 64-bit machine uses 64-bit pointers. To allow you to write portable code, the FPC system unit introduces the types PtrInt and PtrUInt which are signed and unsigned integer data types with the same size as a pointer.

On older compilers, an integer was 16 bits, and represented values from 2-15 through 215-1, or -32,768 through 32,767. A similar data type, word, was sometimes used to define an unsigned integer (0..65,535). In such cases where the compiler used a 16-bit integer type, 32-bit integers would usually be expressed by the data type long or longint.

For x86 machines, an integer is generally defined as 32 bits, and encompasses the values of 2-31 through 231-1, or -2,147,483,648 .. 2,147,483,647. The latter value is also defined as the constant maxint. The unsigned 32 bit integer type cardinal has a range of 0 through 232-1 or 0 .. 4,294,967,295.

On newer 64-bit processors an integer may be defined as a value of 2-63 through 263-1, or -9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807.