什么是序数类型

newgina 2003-06-28 08:41:37
什么是序数类型

小弟初学delphi,在书上看到有个类型是序数类型。说那是有序值的集合。对整数类型值来说值的序号就是值的本身。不太明白这是什么意思。他相当于其他语言的什么类型呢,还是其他语言没有。谢谢。
...全文
304 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxz7531 2003-06-28
  • 打赏
  • 举报
回复
这个问题的完整说明在这里,英文的,勉强看吧

Ordinal types include “integer, character, Boolean, enumerated, and subrange types”. An ordinal type defines an ordered set of values in which each value except the first has a unique predecessor and each value except the last has a unique successor. Further, each value has an ordinality which determines the ordering of the type. In most cases, if a value has ordinality n, its predecessor has ordinality n ?1 and its successor has ordinality n + 1.

For integer types, the ordinality of a value is the value itself.
Subrange types maintain the ordinalities of their base types.
For other ordinal types, by default the first value has ordinality 0, the next value has ordinality 1, and so forth. The declaration of an enumerated type can explicitly override this default.

Several predefined functions operate on ordinal values and type identifiers. The most important of them are summarized below.

Function Parameter Return value Remarks
Ord ordinal expression ordinality of expression抯 value Does not take Int64 arguments.
Pred ordinal expression predecessor of expression抯 value Do not use on properties that have a write procedure.
Succ ordinal expression successor of expression抯 value Do not use on properties that have a write procedure.
High ordinal type identifier or variable of ordinal type highest value in type Also operates on short-string types and arrays.
Low ordinal type identifier or variable of ordinal type lowest value in type Also operates on short-string types and arrays.
For example, High(Byte) returns 255 because the highest value of type Byte is 255, and Succ(2) returns 3 because 3 is the successor of 2.
The standard procedures Inc and Dec increment and decrement the value of an ordinal variable. For example, Inc(I) is equivalent to I := Succ(I) and, if I is an integer variable, to I := I + 1.
newgina 2003-06-28
  • 打赏
  • 举报
回复
在实际应用中怎么用或是什么情况下会用到呢
这个pascal中有吗?完了pascal全忘光了
cxz7531 2003-06-28
  • 打赏
  • 举报
回复
序数类型就是数学上的可列类型,可以列成一个数列。比如:整数、枚举等

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧