Ordinal Types

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's value

Does not take Int64 arguments.

Pred

ordinal expression

predecessor of expression's value

Succ

ordinal expression

successor of expression's value

High

ordinal type identifier or variable ofhighest value in type ordinal type

Also operates on short-string types and arrays.

Low

ordinal type identifier or variable oflowest value in type ordinal 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.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment