1/39
Looks like no tags are added yet.
Data type
defines a collection of data values and a set of predefined operations on those values
Data type
used to easily represent information related to real-world problems
Better error detection
why do we have data types? (1)
Better documentation
why do we have data types? (2)
Primitive Data Types
data types that are not defined in terms of other types
Numeric Types
data types that represent numbers
Integer
represent mathematical integers
2^ (n-1) -1
base of integers, signed or unsigned
Integer
can be implemented using signed-magnitude notation, one’s complement and two’s complement
Floating Point
models real numbers, but most representations are only approximations
Float
standard size; used for single-precision values
Double
twice as long as float types; used for double-precision values
Complex
used to represent complex numbers
Decimal
stores a fixed number of decimal digits, with the decimal point at a fixed position in the value
BCD
each decimal digit is represented by a fixed number of bits
Binary Coded Decimal
meaning of BCD
Boolean Types
value is either true or false
Boolean Types
usually used as flags; makes code more readable
Smallest Efficiently
they are stored in the _ _ accessible cell of memory
Character Type
represents a single character; they are stored in computers as numeric encodings
Character String Types
aka strings; data types whose values consist of sequence of characters
Implementation
implementing strings as a primitive type increases the writability of a language
String length
should _ _ be static or dynamic?
Static Length
string length is fixed once created
Limited Dynamic Length Strings
string length may be within a certain limit assigned during declaration
Dynamic Length Strings
string length may change without any limitations
Additional overhead
dynamic length strings, despite being flexible the _ _ must also be considered
String Assignment
most common operations on strings (1)
String concatenation
most common operations on strings (2)
Substring Reference
returns a reference to the first occurrence of the substring being searched
Lexical Comparison
checks if a string is lexically greater than or less than or equal to another string
Pattern Matching
checks if a string follows a given pattern
Address of the first Char
tells where the string is in the memory
Address of the first char
static length and limited dynamic length strings are bound to storage only once
Complex Memory Management
Address of the first char, dynamic length strings requires _ _ _
Linked list, Adjacent Memory Cells
Address of the first char, dynamic length can be implemented using _ _ or _ _ _
String Type
specifies the type of the string
Fixed
string length, for static strings ->its _ length
Current
string length, for dynamic strings ->its _ length
Current, Max
string length, for limited dynamic strings ->its _ length and _ length