Midterm Review Flashcards
(205 cards)
Defines a collection of data objects and a set of predefined operations on those objects
Data type
The collection of the attributes of a variable
Descriptor
Represents an instance of a user-defined (abstract data) type
Object
Only design issue for all data types:
What operations are defined and how are they specified?
Those not defined in terms of other data types
Primitive data types
Uses of type system of a programming language
- Error detection
- Assistance it provides for program modularization
- Documentation
Defines how a type is associated with each expression in the language and includes its rules for type equivalence and type compatibility.
Type system
How do user-defined types improve readability and modifiability?
User-defined types provide improved readability through the use of meaningful names for types. They allow type checking of the variables of a special category of use, which would otherwise not be possible.
User-defined types also aid modifiability: A programmer can change the type of a category of variables in a program by changing a type definition statement only.
Most common structured (nonscalar) data types in the imperative languages are:
Arrays and records
What are the primitive data types?
- Integer
- Floating point
- Complex
- Decimal
- Boolean types
- Character types
Two floating point types
Float and double
The accuracy of the fractional part of a value, measured as the number of bits.
Precision
A combination
of the range of fractions and, more important, the range of exponents.
Range
The most common primitive data type
Integer
Java four signed integer sizes:
byte, short, int, long
A negative integer could be stored in….
sign-magnitude notation
Two types of notation
Twos complement and ones complement
The representation of a negative number is formed by taking the logical complement of the positive version of the number and adding one.
Twos complement notation
The negative of an integer is stored as the logical complement of its absolute value.
Ones complement notation
Floating-point values are represented as ___ and ____
fractions and exponents
Floating-point values use a form that is borrowed from ______________
scientific notation
Complex values are representes as____________
ordered pairs of floating-point values
Advantage of decimal types
Accuracy. Being able to precisely store decimal values, at least those within a restricted range.
Disadvantage of decimal types
- Range of values is restricted because no exponents are allowed.
- Wastes memory