Chapter 2 – Simple Types: Enumerations, Numbers and Date/Times
Chapter 2 of Delphi XE2 Foundations covers Delphi's simple types in depth — from enumerated types and sets through to integers, floating-point numbers, and date/time handling. These types form the bedrock of everyday Delphi programming.
Enumerated Types
Delphi's enumerated types allow you to define a fixed set of named values. The chapter covers:
- Enumerated type basics and ordinal type standard routines
- Enumerated type scoping rules
- Converting to and from raw ordinal values
- Converting to and from string values
Sets
Sets build on enumerated types to represent collections of values from a single ordinal type. Topics include:
- Adding and removing items from a set
- Enumerating and testing set membership
- Manual 'sets' using bitwise operators
Working with Numbers: Integers
The chapter examines Delphi's integer types and the operations available for them:
- Integer types and their ranges
- Integer literals and operator precedence
- Intrinsic routines and commonly-used integer functions
- Converting between numeric representations
Real Numbers: Floating Point Types
Floating-point coverage includes the standard real types, precision considerations, and the mathematical routines provided by the runtime library.
Dates, Times and Timings
Delphi's TDateTime type and related routines for working with dates, times, and measuring elapsed intervals are explained, along with formatting and conversion techniques.