当前位置:网站首页>[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 .
边栏推荐
- What material is sa537cl2 equivalent to in China? Sa537cl2 corresponding material
- What is the maximum number of concurrent TCP connections for a server? 65535?
- UCORE overview
- Develop team OKR in the way of "crowdfunding"
- IDEA-配置插件
- How to promote cross department project collaboration | community essay solicitation
- PHP CI (CodeIgniter) log level setting
- Interviewer: how does the JVM allocate and recycle off heap memory
- QT串口ui设计和解决显示中文乱码
- utfwry. Dat PHP, about ThinkPHP's method of IP location using utfwry address Library
猜你喜欢
UCORE overview
[solved] access denied for user 'root' @ 'localhost' (using password: yes)
Add color to the interface automation test framework and realize the enterprise wechat test report
Cocos Creator 2.x 自动打包(构建 + 编译)
8 cool visual charts to quickly write the visual analysis report that the boss likes to see
word 退格键删除不了选中文本,只能按delete
2022.02.14_ Daily question leetcode five hundred and forty
What is the maximum number of concurrent TCP connections for a server? 65535?
To resist 7-Zip, list "three sins"? Netizen: "is the third key?"
Processing strategy of message queue message loss and repeated message sending
随机推荐
Web crawler knowledge day03
[combinatorial mathematics] counting model, common combinatorial numbers and combinatorial identities**
2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
What kind of material is 14Cr1MoR? Analysis of chemical composition and mechanical properties of 14Cr1MoR
The way of wisdom (unity of knowledge and action)
8个酷炫可视化图表,快速写出老板爱看的可视化分析报告
CC2530 common registers for port interrupts
LeetCode 1656. Design ordered flow
function overloading
Record windows10 installation tensorflow-gpu2.4.0
Necessary ability of data analysis
What is the difference between 14Cr1MoR container plate and 14Cr1MoR (H)? Chemical composition and performance analysis of 14Cr1MoR
于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
Construction practice camp - graduation summary of phase 6
A survey of state of the art on visual slam
The word backspace key cannot delete the selected text, so you can only press Delete
Hands on in-depth learning notes (XIV) 3.7 Simple implementation of softmax regression
Network security web penetration technology
【剑指 Offer】58 - II. 左旋转字符串
Aike AI frontier promotion (7.3)