当前位置:网站首页>[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 .
边栏推荐
- 【LeetCode】94. Middle order traversal of binary tree
- Hands on in-depth learning notes (XIV) 3.7 Simple implementation of softmax regression
- "The NTP socket is in use, exiting" appears when ntpdate synchronizes the time
- Is it safe to open a stock account by mobile registration? Does it need money to open an account
- Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day
- Recommendation of good books on learning QT programming
- NSQ source code installation and operation process
- Leetcode binary search tree
- BYD and great wall hybrid market "get together" again
- Top k questions of interview
猜你喜欢
Daily code 300 lines learning notes day 10
[solved] access denied for user 'root' @ 'localhost' (using password: yes)
NSQ source code installation and operation process
Mysql database -dql
Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer
Cocos Creator 2. X automatic packaging (build + compile)
Explore Netease's large-scale automated testing solutions see here see here
MySQL single table field duplicate data takes the latest SQL statement
Arduino esp32: overall framework of lvgl project (I)
IDEA-配置插件
随机推荐
What material is sa537cl1? Sa537cl1 corresponds to the national standard material
[combinatorics] recursive equation (example 1 of recursive equation | list recursive equation)
Record windows10 installation tensorflow-gpu2.4.0
word 退格键删除不了选中文本,只能按delete
RF Analyze Demo搭建 Step by Step
Is it safe to open a stock account by mobile registration? Does it need money to open an account
消息队列消息丢失和消息重复发送的处理策略
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
IL Runtime
mysql用户管理
跟我学企业级flutter项目:简化框架demo参考
CC2530 common registers for port initialization
arduino-esp32:LVGL项目(一)整体框架
MySQL user management
Cocos Creator 2.x 自动打包(构建 + 编译)
The word backspace key cannot delete the selected text, so you can only press Delete
LeetCode 1658. Minimum operand to reduce x to 0
[solved] access denied for user 'root' @ 'localhost' (using password: yes)
PHP converts a one-dimensional array into a two-dimensional array
于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日