Data type: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Data type
| Old | New | Line | |
|---|---|---|---|
| 1 | + | # General | |
| 2 | + | ||
| 3 | + | This page provides an assortment of data types in Free Pascal. | |
| 4 | + | ||
| 5 | + | A **data type** is a template for a [[Data field|data field]]. | |
| 6 | + | ||
| 7 | + | The data type of a field defines how the compiler and processor interpret it's content. | |
| 8 | + | ||
| 9 | + | The visibility of a [[Data field|data field]] depends on the location of it's declaration. | |
| 10 | + | ||
| 11 | + | # Integer types | |
| 12 | + | ||
| 13 | + | ## Unsigned types | |
| 14 | + | ||
| 15 | + | [[Data field|Data fields]] of unsigned integral types can only contain **positive** integral numbers. | |
| 16 | + | ||
| 17 | + | - [[UInt8]] - Range: (0 .. 255) | |
| 18 | + | - [[Byte]] - Range: (0 .. 255) | |
| 19 | + | - [[UInt16]] - Range: (0 .. 65535) | |
| 20 | + | - [[Word]] - Range: (0 .. 65535) | |
| 21 | + | - [[NativeUInt]] - Range: depends on the processor type. | |
| 22 | + | - [[DWord]] - is equivalent to Longword. | |
| 23 | + | - [[Cardinal]] - is equivalent to Longword. | |
| 24 | + | - [[UInt32]] - Range: (0 .. 4294967295) | |
| 25 | + | - [[Longword]] - Range: (0 .. 4294967295) | |
| 26 | + | - [[UInt64]] - Range: (0 .. 18446744073709551615) | |
| 27 | + | - [[QWord]] - Range: (0 .. 18446744073709551615) | |
| 28 | + | ||
| 29 | + | ## Signed types | |
| 30 | + | ||
| 31 | + | [[Data field|Data fields]] of signed integral types can contain positive **and** negative integral numbers. | |
| 32 | + | ||
| 33 | + | - [[Int8]] - Range: (-128 .. 127) | |
| 34 | + | - [[Shortint|ShortInt]] - Range: (-128 .. 127) | |
| 35 | + | - [[Int16]] - Range: (-32768 .. 32767) | |
| 36 | + | - [[Smallint|SmallInt]] - Range: (-32768 .. 32767) | |
| 37 | + | - [[Integer]] - Range: is equivalent either to Smallint or Longint (for 16 respectively 32 bit processors). | |
| 38 | + | - [[Int32]] - Range: (-2147483648 .. 2147483647) | |
| 39 | + | - [[NativeInt]] - Range: depends on the processor type. | |
| 40 | + | - [[Longint|LongInt]] - Range: (-2147483648 .. 2147483647) | |
| 41 | + | - [[Int64]] - Range: (-9223372036854775808 .. 9223372036854775807) | |
| 42 | + | ||
| 43 | + | # Floating-point types | |
| 44 | + | ||
| 45 | + | [[Data field|Data fields]] of a floating-point type can contain: | |
| 46 | + | ||
| 47 | + | 1. positive **and** negative integral numbers with possible round-off errors. | |
| 48 | + | 2. positive **and** negative floating-point numbers. | |
| 49 | + | ||
| 50 | + | - [[Single]] - Range: (1.5E-45 .. 3.4E38) | |
| 51 | + | - [[Real]] - Range: depends on the platform. | |
| 52 | + | - [[Real48]] - Range: 2.9E-39 .. 1.7E38 | |
| 53 | + | - [[Double]] - Range: (5.0E-324 .. 1.7E308) | |
| 54 | + | - [[Extended]] - Range: depends on the platform. | |
| 55 | + | - [[Comp]] - Range: (-2E64+1 .. 2E63-1) | |
| 56 | + | - [[Currency]] - Range: (-922337203685477.5808 .. 922337203685477.5807) | |
| 57 | + | ||
| 58 | + | # Boolean types | |
| 59 | + | ||
| 60 | + | [[Data field|Data fields]] of boolean type contain truth values. | |
| 61 | + | ||
| 62 | + | - [[Boolean]] - Range: (True, False), 8 Bit | |
| 63 | + | - [[Bytebool|ByteBool]] - Range: (True, False), 8 Bit | |
| 64 | + | - [[Wordbool|WordBool]] - Range: (True, False), 16 Bit | |
| 65 | + | - [[Longbool|LongBool]] - Range: (True, False), 32 Bit | |
| 66 | + | ||
| 67 | + | # Enumeration types | |
| 68 | + | ||
| 69 | + | [[Data field|Data fields]] of an enumeration type are "lists" (enumerations...) of integral unsigned constants. | |
| 70 | + | ||
| 71 | + | - [[Enum Type]] - Range: (integral data types) | |
| 72 | + | ||
| 73 | + | # Char types | |
| 74 | + | ||
| 75 | + | ## Char types with single byte encoding | |
| 76 | + | ||
| 77 | + | - [[Char]] - Constant length: 1 byte, representation: 1 character. | |
| 78 | + | - [[Shortstring|ShortString]] - Maxmimum length: 255 characters. | |
| 79 | + | - [[String]] - Maxmimum length: Shortstring or Ansistring (depends in the used compiler switch). | |
| 80 | + | - [[PChar]] - Pointer to a null-terminated string without length restriction. | |
| 81 | + | - [[Ansistring|AnsiString]] - No length restriction. | |
| 82 | + | - [[Pansichar|PAnsiChar]] - Pointer to a null-terminated string without length restriction. | |
| 83 | + | ||
| 84 | + | See the overview of the different [[Character and string types|character and string types]]. | |
| 85 | + | ||
| 86 | + | ## Char types with multi byte encoding | |
| 87 | + | ||
| 88 | + | (The encoding with 2 or 4 bytes is system dependent.\ | |
| 89 | + | ||
| 90 | + | - [[WideChar]] - Constant length: 2 or 4 bytes, representation: 1 character. | |
| 91 | + | - [[Widestring|WideString]] - No length restriction. | |
| 92 | + | - [[Pwidechar|PWideChar]] - Pointer to a null-terminated wide string without length restriction. | |
| 93 | + | - [[Unicodechar|UnicodeChar]] - Constant length: 2 or 4 bytes, representation: 1 character. | |
| 94 | + | - [[Unicodestring|UnicodeString]] - No length restriction. | |
| 95 | + | - [[Punicodechar|PUnicodeChar]] - Pointer to a null-terminated Unicode string without length restriction. | |
| 96 | + | ||
| 97 | + | See the overview of the different [[Character and string types|character and string types]]. | |
| 98 | + | ||
| 99 | + | # Variant types | |
| 100 | + | ||
| 101 | + | - [[Variant]] | |
| 102 | + | - [[Olevariant]] | |
| 103 | + | ||
| 104 | + | # Constants | |
| 105 | + | ||
| 106 | + | - Untyped constants | |
| 107 | + | - [[Const]] - Only simple data types can be used. | |
| 108 | + | - Typed constants | |
| 109 | + | - [[Const]] - Simple data types as well as records and arrays can be used. | |
| 110 | + | - Resource Strings | |
| 111 | + | - [[Resourcestring]] - Used for localisation (not available in all compiler modes). | |
| 112 | + | ||
| 113 | + | # Structural types | |
| 114 | + | ||
| 115 | + | - [[Array]] - The size of the array depends on the type and the number of elements it contains. | |
| 116 | + | - [[Record]] - A combination of multiple data types. | |
| 117 | + | - [[Set]] - A set of elements of an ordinal type; the size depends on number of elements it contains. | |
| 118 | + | ||
| 119 | + | # Subrange types | |
| 120 | + | ||
| 121 | + | - [[subrange types]] are a subset of a base type. | |
| 122 | + | ||
| 123 | + | # Pointer | |
| 124 | + | ||
| 125 | + | - [[Pointer]] - The size depends on the processor type. | |
| 126 | + | ||
| 127 | + | # Classes and objects | |
| 128 | + | ||
| 129 | + | - [[Object]] - Developed under Turbo Pascal 5.5 for DOS and the precursor of class. | |
| 130 | + | - [[Class]] - Developed under Delphi 1.0 for Windows and the successor of object. | |
| 131 | + | ||
| 132 | + | # See also | |
| 133 | + | ||
| 134 | + | - [[Pascal basics]] | |
| 135 | + | ||
| 136 | + | --- | |
| 137 | + | *From the Free Pascal wiki, page "Data type", as it stood on 2021-08-29 after a change by Mozi, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
