当前位置:网站首页>[2. Basics of Delphi grammar] 2 Object Pascal data type
[2. Basics of Delphi grammar] 2 Object Pascal data type
2022-07-03 16:47:00 【Janeb1018】
2.Object Pascal data type
Object Pascal Is a strong type of language , Definition of data type 、 There are strict syntax rules for declarations, data assignment and transfer operations .Object Pascal The data types of can be divided into standard data types and advanced data types , It also supports custom types . This section mainly studies standard data types .
Standard data type :
Integer integer
Real floating-point
Charactor Character
String String type
Boolean Boolean type
Advanced data types :
Enumerated enum
Subrange Subboundary type
Set Collection types
Array An array type
Record Record type
File file type
Class Class types
Class Reference Class reference type
Interface Interface type
Pointer Pointer types
Procedural Process type
Variant Variable type
In data types , integer 、 Character 、 Boolean type 、 Enumerations and subjunctions are called sequential types , Its value is an ordered set , Every possible value depends on the order , That is to say, its value corresponds to an integer .
2.1 Numerical data type
1. Integer types
Object Pascal Integer type in :
| Type the name | The word is long | type | Space |
|---|---|---|---|
| ShortInt | 8 Bit signed integer | Short | -128~127 |
| Byte | 8 Bit unsigned integer | Byte type | 0~255 |
| SmallInt | 16 Bit signed integer | Small integer | -32768~32767 |
| Word | 16 Bit unsigned integer | Font type | 0~65536 |
| Integer | 32 Bit signed integer | integer | -2147483648~2147483647 |
| Longword | 32 Bit unsigned integer | Long type | 0~4294967295 |
| Longint | 32 Bit signed integer | Long integer | -2147483648~2147483647 |
| Cardinal | 32 Bit unsigned integer | Ordinal type | 0~4294967295 |
| Int64 | 64 Bit signed integer | 64 An integer | -2^63~2^63 |
When using integer type , Try to use Integer and Cardinal data type , Because these two data types can maximize CPU and OS Performance of .
2. Real number type
Object Pascal Real number type in :
| Type the name | The word is long | type | Space | Effective bit |
|---|---|---|---|---|
| Single | 4 Byte float | Single-precision floating-point | ±1.5*10^-39 ~ 3.4*10^38 | 7 or 8 |
| Real | 6 Byte float | Real type | ±5.0*10^-324 ~ 1.7*10^308 | 15 or 16 |
| Double | 8 Byte float | Double precision floating point | ±5.0*10^-324 ~ 1.7*10^308 | 15 or 16 |
| Extended | 10 Byte float | Extended | ±3.6*10^-4951 ~ 1.1*10^4932 | 19 or 20 |
| Currency | 64 Bit monetary value | Currency type | -922337203685477.5808 ~922337203685477.5807 | 19 or 20 |
stay Object Pascal in ,Real The type and Double Types are completely equivalent ,Extended Type ratio Real Type has higher precision , But the compatibility with other platforms is poor , So try to avoid using Extended type .Currentcy Types are specifically designed to handle monetary values , This type must have at least 4 Valid decimal places .
2.2 Character data type
1. Character type
Character types are data types that store single character data ,Object Pascal Character data types in :
| Type the name | type | Space | Value range |
|---|---|---|---|
| AnsiChar | Ansi Character | 1 | Expand ANSI Character set |
| WideChar | Wide character | 2 | Unicode Character set |
| Char | Character | 1 | Expand ANSI Character set |
Char The type and AnsiChar Types are completely equivalent ; The most commonly used character type is Char type .
2. String type
String type is the data type that stores string data ,Object Pascal String data type in :
| Type the name | type | Maximum length | Memory space |
|---|---|---|---|
| ShortString | Short string | 255 | 2 ~ 256B |
| AnsiString | Long string | 2^31 | 4B ~ 2GB |
| WideString | Wide string | 2^30 | 4B ~ 2GB |
| String | String type | 2^31 | 4B ~ 2GB |
ShortString Type and traditional Pascal The string corresponding to , For forward compatibility
AnsiString The definition of type is dynamically allocated , With empty characters Null As the end of a string
String The type can be either ShortString type , It can also be AnsiString type , The default definition is AnsiString type
stay Delphi The properties of many components in are used String type
2.3 Boolean data type
Boolean data types are used for relational operations and logical operations of conditional statements ,Object Pascal Medium Boolean data type :
| Type the name | type | Number of bytes | Value |
|---|---|---|---|
| Boolean | Boolean type | 1 | 0(False)|1(True) |
| ByteBool | Byte Boolean | 1 | 0(False)| Not 0(True) |
| WordBool | Wide Boolean | 2 | 0(False)| Not 0(True) |
| LongBool | Long Boolean | 4 | 0(False)| Not 0(True) |
Boolean The value of type is False and True Two symbolic constants , When programming, try to use Boolean type ; Because other types are set for compatibility with other languages .
边栏推荐
- AcWing 第58 场周赛
- Informatics Olympiad all in one YBT 1175: divide by 13 | openjudge noi 1.13 27: divide by 13
- Extraction of the same pointcut
- What is the maximum number of concurrent TCP connections for a server? 65535?
- function overloading
- 执行脚本不认\r
- The word backspace key cannot delete the selected text, so you can only press Delete
- Cocos Creator 2. X automatic packaging (build + compile)
- CC2530 common registers for port interrupts
- 浅谈拉格朗日插值及其应用
猜你喜欢

(补)双指针专题

Le zèbre a été identifié comme un chien, et la cause de l'erreur d'AI a été trouvée par Stanford

Mysql database -dql
![[solved] access denied for user 'root' @ 'localhost' (using password: yes)](/img/71/1ff8ed1d773da99054310f96dca3f8.jpg)
[solved] access denied for user 'root' @ 'localhost' (using password: yes)

CC2530 common registers for timer 1

What material is sa537cl2? Analysis of mechanical properties of American standard container plate

Kotlin学习快速入门(7)——扩展的妙用

Aike AI frontier promotion (7.3)
![[combinatorics] non descending path problem (number of non descending paths with constraints)](/img/89/bd1a2ddd9632ab5d4b4bee9336be51.jpg)
[combinatorics] non descending path problem (number of non descending paths with constraints)

What material is 12cr1movr? Chemical property analysis of pressure vessel steel plate 12cr1movr
随机推荐
中南大学|通过探索理解: 发现具有深度强化学习的可解释特征
13mnnimo5-4 German standard steel plate 13MnNiMo54 boiler steel 13MnNiMo54 chemical properties
Netease UI automation test exploration: airtest+poco
Golang decorator mode and its use in NSQ
斑馬識別成狗,AI犯錯的原因被斯坦福找到了
网络安全web渗透技术
什么是质押池,如何进行质押呢?
Construction practice camp - graduation summary of phase 6
[combinatorics] non descending path problem (number of non descending paths with constraints)
Nifi from introduction to practice (nanny level tutorial) - flow
Mongodb installation and basic operation
Characteristic polynomial and constant coefficient homogeneous linear recurrence
为抵制 7-Zip,列出 “三宗罪” ?网友:“第3个才是重点吧?”
Threejs Part 2: vertex concept, geometry structure
Thread pool executes scheduled tasks
Idea configuration plug-in
[combinatorics] polynomial theorem (polynomial theorem | polynomial theorem proof | polynomial theorem inference 1 item number is the number of non negative integer solutions | polynomial theorem infe
PHP converts a one-dimensional array into a two-dimensional array
2022.02.14_ Daily question leetcode five hundred and forty
What material is sa537cl2? Analysis of mechanical properties of American standard container plate