Friday, October 16, 2009

1.2 Data Types

There are two types of data, namely, atomic and structured (also called composite) data.

Atomic data are data that we choose to consider as a single, non-decomposable entity. Boolean or logical data are examples. The integer 4562 may be considered as a single integer value. We can decompose it into single digits (4,5,6,2) but decomposed digits will not have the same characteristics of the original integer.

An Atomic Data Type is a set of atomic data with identical properties. These properties distinguish one atomic data type from another. Atomic data types are defined by a domain or set of values and a set of operations that act on the values. These are data types that are defined without imposing any structure on their values. For example, we can define some atomic data types shown below

1. Boolean or Logical

Values: two values, namely, true or false

Operations: many including AND, OR, NOT etc

2. Integer

Values: -¥,….,-2, -1, 0, 1, 2,…..¥

Operations: *,+, -, %, /, ++.- -,….

3. Floating Point

Values: -¥,….,0.0, …,¥

Operations: *,+, -, /,….

4. Character

Values, 0,1,…9,A,B,…Z,a,b,…z

Operations: <, >…

Structured (or composite) Data types are opposite of atomic type. A structured data type has a definition that imposes structure upon its values. One can also say that data can be broken into pieces that have meaning. They are implemented using structure statements such as struct.

As an example of Structured Data type, consider the example, of data type fraction, like .

–Domain specification for fraction needs a structure. The value of a fraction is made of three parts (or components):

· A sign, which is either + or –

· A numerator, which may be any non-negative integer

· A denominator, which may be any positive (not zero) integer

The three parts themselves have specific types, and there may be further constraints. In many structured data types, there is an internal relationship, or organization that holds between components. If we think of an array as a structured type, with each position in the array being a component, then there is a structured relationship of ‘followed by’. : We say that component N is followed by component N+1.

No comments:

Post a Comment