当前位置:网站首页>[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 .
边栏推荐
- Threejs Part 2: vertex concept, geometry structure
- What is the pledge pool and how to pledge?
- word 退格键删除不了选中文本,只能按delete
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- 跟我学企业级flutter项目:简化框架demo参考
- Arduino esp32: overall framework of lvgl project (I)
- Eleven requirements for test management post
- QT serial port UI design and solution to display Chinese garbled code
- mysql用户管理
- 智慧之道(知行合一)
猜你喜欢

Web crawler knowledge day03

What is the pledge pool and how to pledge?

What material is 12cr1movr? Chemical property analysis of pressure vessel steel plate 12cr1movr

Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day

美团一面:为什么线程崩溃崩溃不会导致 JVM 崩溃

MySQL Basics

线程池执行定时任务

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

Record windows10 installation tensorflow-gpu2.4.0

Kotlin学习快速入门(7)——扩展的妙用
随机推荐
CC2530 common registers for port initialization
CC2530 common registers for crystal oscillator settings
Basis of target detection (IOU)
Register in PHP_ Globals parameter settings
Mysql database DDL and DML
为抵制 7-Zip,列出 “三宗罪” ?网友:“第3个才是重点吧?”
[solved] access denied for user 'root' @ 'localhost' (using password: yes)
[mathematical logic] equivalent calculus and reasoning calculus of propositional logic (propositional logic | equivalent calculus | principal conjunctive (disjunctive) paradigm | reasoning calculus)**
Arduino esp32: overall framework of lvgl project (I)
[combinatorics] recursive equation (outline of recursive equation content | definition of recursive equation | example description of recursive equation | Fibonacci Series)
Overview of satellite navigation system
MySQL single table field duplicate data takes the latest SQL statement
2022爱分析· 国央企数字化厂商全景报告
ThreeJS 第二篇:顶点概念、几何体结构
How to promote cross department project collaboration | community essay solicitation
Visual SLAM algorithms: a survey from 2010 to 2016
消息队列消息丢失和消息重复发送的处理策略
CC2530 common registers for watchdog
Interpretation of several important concepts of satellite antenna
Summary of three methods of PHP looping through arrays list (), each (), and while