Data representation
In this chapter, you will learn about
How to define user-defined data types
Understand the definition and use of non-composite and composite data
types
Strategies for choosing and designing an appropriate user-defined data type
for a given problem
methods of file organization, such as serial, sequential and random
methods of file access, such as sequential and direct access
hashing algorithms
binary floating-point real numbers
How to convert binary floating-point real numbers into denary numbers
converting denary numbers into binary floating-point real numbers
the normalization of binary floating-point numbers
how underflow and overflow can occur
how binary representation can lead to rounding errors.
User-Defined Data Type (UDT)
A User-Defined Data Type (UDT) is a data type created by programmers to represent
complex data structures or specific data that cannot be directly handled using
predefined (built-in) data types. UDTs allow developers to define a structure that
combines multiple data fields or custom behaviors to better model real-world
entities in programming.
User-defined data types can be divided into
non-composite and
composite data types.
Non-composite data types
A non-composite data type can be defined without referencing another data type. It
can be a primitive type available in a programming language or a user-defined data
type. Non-composite user-defined data types are usually used for a special purpose.
We will consider enumerated data types for lists of items and pointers to data in a
computer’s memory.
Enumerated data type
An enumerated data type contains no references to other data types when it is
defined. In pseudocode, the type definition for an enumerated data type has this
structure:
For example, a data type for months of the year could be defined as:
Then the variables thisMonth and nextMonth of type Tmonth could be defined as:
Pointer data type
A pointer data type is used to reference a memory location. This data type needs
to have information about the type of data that will be stored in the memory
location.
In pseudocode the type definition has the following structure, in which ^ shows that
the type being declared is a pointer and <Typename> is the type of data to be
found in the memory location, for example INTEGER or REAL, or any user-defined
data type.