当前位置:网站首页>[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 .
边栏推荐
- Capacités nécessaires à l'analyse des données
- Simulink oscilloscope data is imported into Matlab and drawn
- Aike AI frontier promotion (7.3)
- Pointcut expression
- MySQL single table field duplicate data takes the latest SQL statement
- 数据分析必备的能力
- Interviewer: how does the JVM allocate and recycle off heap memory
- One article takes you to understand machine learning
- Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
- What material is 12cr1movr? Chemical property analysis of pressure vessel steel plate 12cr1movr
猜你喜欢

CC2530 common registers for crystal oscillator settings

Data driving of appium framework for mobile terminal automated testing
The way of wisdom (unity of knowledge and action)

关于学习Qt编程的好书精品推荐

斑马识别成狗,AI犯错的原因被斯坦福找到了

arduino-esp32:LVGL项目(一)整体框架

TCP congestion control details | 3 design space

Unreal_ Datatable implements ID self increment and sets rowname

Visual SLAM algorithms: a survey from 2010 to 2016

Arduino esp32: overall framework of lvgl project (I)
随机推荐
斑馬識別成狗,AI犯錯的原因被斯坦福找到了
什么是质押池,如何进行质押呢?
14 topics for performance interviews between superiors and subordinates (4)
特征多项式与常系数齐次线性递推
One article takes you to understand machine learning
CC2530 common registers for port interrupts
深入理解 SQL 中的 Grouping Sets 语句
Summary of three methods of PHP looping through arrays list (), each (), and while
What is the material of 13mnnimor? 13mnnimor steel plate for medium and low temperature pressure vessels
中南大学|通过探索理解: 发现具有深度强化学习的可解释特征
word 退格键删除不了选中文本,只能按delete
浅谈拉格朗日插值及其应用
IL Runtime
Learn from me about the enterprise flutter project: simplified framework demo reference
NSQ source code installation and operation process
數據分析必備的能力
Hong Kong Polytechnic University | data efficient reinforcement learning and adaptive optimal perimeter control of network traffic dynamics
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Everyone in remote office works together to realize cooperative editing of materials and development of documents | community essay solicitation
Construction practice camp - graduation summary of phase 6