Skip to content

Ordinal Data Type

An ordinal data type gives its language-defined values ordered integer positions that support stepping and contiguous subranges.

Version
v3 · 2026-11-14 · History
Domain-specific #
13482
Domain group
Applied Sciences & Engineering
Origin domain
Computer Science & Software Engineering
Subdomain
Discrete Types → Computer Science & Software Engineering
Aliases
Ordinal Type

Core Idea

An ordinal data type has values whose language-defined order assigns integer positions, supporting position, predecessor/successor and contiguous-subrange operations. ISO Pascal calls integer, Boolean, character, enumeration and subrange types ordinal. Ada calls enumeration and integer types discrete and likewise assigns positions, but the two language categories should not be declared identical in every edge case.[1][2]

How would you explain it like I'm…

Values in a Line

In some computer languages, certain kinds of values come in a set line, like the days of the week, and each one has a spot number. An ordinal data type is that kind of value. The computer can tell you which spot a value is in, what comes next, and what came before.

Values With Place Numbers

When you write programs, you use different kinds of data, like numbers, letters, and true-or-false values. An ordinal data type is a kind whose values come in a fixed order that the programming language defines, and each value has a whole-number position. Because of this, you can ask for a value's position, get the next or previous value, or use a stretch of values, like Monday through Friday. In the language Pascal, whole numbers, true/false, characters, and lists of named values count as ordinal, but decimal numbers do not. The language has to set this up; it isn't enough that the values could be counted.

Language-Defined Ordered Value Type

An ordinal data type is a type whose values form an ordered set defined by the programming language, with each value given an integer position. Operations use that order: finding a value's position, moving to its successor or predecessor, and defining a contiguous subrange. ISO Pascal uses the term 'ordinal-type' for integer, Boolean, char, enumerated, and subrange types, while real is a separate kind of simple type. Ada calls enumeration and integer types 'discrete types' and also gives them position numbers; for example, a Day enumeration with a Weekday subtype. This isn't the same as the math fact that any countable set can be numbered: strings are countable, but that doesn't give them Pascal's ord and succ operations. The language must define the values, their order, the allowed operations, and what happens at the ends.

 

An ordinal data type is a type whose values form a language-defined ordered set with integer positions, supporting operations such as obtaining a position, taking successor or predecessor, and specifying a contiguous subrange. ISO Pascal uses the term ordinal-type explicitly: integer, Boolean, char, enumerated, and subrange types qualify, whereas real is a separate simple type. Ada's Reference Manual uses discrete type for enumeration and integer types and likewise assigns position numbers; its Day enumeration and Weekday subtype illustrate the same relation in different vocabulary. The concept is a language-level commitment, not a set-theoretic claim that any countable collection can be indexed by integers. The language must define the values, their order, legal operations, and boundary behavior. A countable collection of strings does not thereby acquire Pascal's ord and succ operations. Moreover, Ada defines a machine successor operation for some non-discrete scalar types, so having a next representable value is not a sufficient cross-language criterion.

Scope of Application

Pascal's standard defines ordinal types and ord, succ, pred; Ada's Reference Manual defines discrete types, their positions and range constraints. Language specification, not mathematical countability, decides admission. Ada's successor attribute also applies to some non-discrete scalar types, so a machine successor alone is not sufficient.[1][2]

Clarity

Pascal's official (red, yellow, green, blue, tartan) enumeration assigns positions 0–4 in declaration order. Thus succ(yellow)=green, pred(red) has no valid result, and its printed red..green subrange comprises only the first three literals. Ada's official Day=(Mon,Tue,Wed,Thu,Fri,Sat,Sun) gives positions 0–6; Weekday is Day range Mon .. Fri excludes Sat and Sun while retaining them as Day values. Day'Succ(Thu)=Fri. These are calculations from the two standards' own examples, not reported compiler runs.[1][3]

Manages Complexity

Semantic positions permit common operations over names that have no inherent numeric meaning. A subrange constrains a larger host type; an endpoint step may fail rather than wrap. This helps distinguish type rules from incidental storage encoding, but each language's own rules govern which uses are legal.[1][2]

Abstract Reasoning

For an ordered type V with position map p, consecutive enumeration values satisfy p(vᵢ₊₁)=p(vᵢ)+1. A contiguous subrange [a,b] takes values with p(a)≤p(v)≤p(b). Reordering Pascal's color literals changes their positions and successors without changing their names. Expanding Ada's Weekday bound to Sun changes subtype membership without changing Day's underlying enumeration.[1][3]

Knowledge Transfer

The useful cross-language diagnostic is to inspect which types a specification classifies as discrete, how it assigns positions, where stepping ends, and how range bounds work. Similar operation names elsewhere do not establish category identity. No universal intrinsic two-sided tension or direct prime parent is asserted; the live Data Type entry is the strict domain-specific parent.[1][2]

Relationships to Other Abstractions

Local relationship map for Ordinal Data TypeParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Ordinal Data TypeDOMAINDomain-specific abstraction: Data Type — is a kind ofData TypeDOMAIN

Current abstraction Ordinal Data Type Domain-specific

Parents (1) — outgoing typed relations

  • Ordinal Data Type is a kind of Data Type Domain-specific

    An ordinal data type is a data type with language-defined integer positions, step operations and contiguous subranges.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Ordinal Data Type sits in a sparse region of the domain-specific corpus (66th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.

Family — Type Systems & Functional Constructs (20 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14

References

[1] ISO/IEC 7185:1990, Programming languages—Pascal, original standard, §§6.4.2.1–6.4.2.4 and §6.6.6.4. registry ↩a ↩b ↩c ↩d ↩e ↩f

[2] Ada 2022 Reference Manual, §3.5 “Scalar Types”: discrete types, positions and scalar successor attributes. registry ↩a ↩b ↩c ↩d

[3] Ada 2022 Reference Manual, §3.5.1 “Enumeration Types”: position rule and Day/Weekday declarations. registry ↩a ↩b