Module 3 - Data Types, Expression and Assignment Statements Flashcards
The basic concept of the representation of data in programming languages
Data type
Data in its most primitive form
A collection of ones and zeros (bits)
Are often part of the application of data concepts
Machine dependencies
Concept of data limits
In math, the set of integer values are infinite. In hardware, there will always be a largest and smallest number.
Program data can be classified according to?
Their types
Represents the possible values that a variable of that type can hold and the way those values are represented internally
Type name
Definition 1: A set of values the statement int x; is the same as x ∈ Integers
Definition 2): a set of values, together with a set of operations on that values having certain properties
Part of mathematical algebra
A class of data objects with a set of operations for creating and manipulating them.
Data type
Specification of data types
Attributes
Values
Operations
A data type specification that classify data objects of a given type by Data type and name – does not vary during the lifetime of the object
These can be stored in a descriptor and utilized during the program execution
These are only utilized to establish the storage representation, not used explicitly during execution
Attributes
A data type specification that defines the values that a data object of that type could get
Typically, they can be a well-ordered set, i.e. it has a least and a greatest value
Values
A data type specification that define the potential manipulations of data objects of that type.
Operations
Operations that are denoted as part of data objects of that type
Primitive
Operations that can be represented as subprograms, or class methods
Programmer-defined
An Operation is defined by:
Domain - set of probable input arguments
Range - set of potential results
Action - how the result is generated
Specifies the domain and the range
Operation signature
Source of ambiguity in operations
Undefined operations for some inputs.
Implicit arguments, e.g. use of global variables
Implicit results - the operation may alter its arguments
Self-modification - typically through change of local data among calls, e.g. random number generators change the seed.
Storage Representation is influenced by the hardware described in terms of:
- Size of the memory blocks required
- Layout of attributes and data values within the block
In storage representation, methods to treat attributes
- established by the compiler and not stored in descriptors during execution - C
- stored in a descriptor as component of the data object at run time - LISP Prolog
Implementation of operations
- Hardware operation - direct implementation (E.g. Integer addition)
- Subprogram/function, e.g. square root operation
- In-line code - code is copied into the program at the point where the subprogram would have been invoked.
Elementary Data Types
Scalar Data Type
Composite Data Types
Data types that represent a single object, i.e. only one value can be derived.
In general, these type of objects follow the hardware architecture of a computer.
Scalar Data Types
Numerical Scalar Data Types
Integers
Sub-ranges
Floating-point real numbers
Fixed-point real numbers
Specification: Maximal and minimal values
Operations:
Arithmetic
Relational
Assignment
Bit operations
Implementation: hardware defined
Integers Scalar Data Type
A scalar data type that is a series of integer values inside some controlled range
Ex: Pascal declaration A: 1..10 means that the variable A may be assigned integer values from 1 through 10.
Specification: subtype of integer
Implementation: smaller storage requirements, better type checking
Sub-ranges Scalar Data Type