Data Types: ISBN 0-321-33025-0
Data Types: ISBN 0-321-33025-0
Data Types
ISBN 0-321-33025-0
Definitions
• Sign bit
• Ones complement
• Boolean
– Range of values: two elements, one for “true” and one for
“false”
– Could be implemented as bits, but often as bytes
• Character
– Stored as numeric codings
– Most commonly used coding: ASCII
– An alternative, 16-bit coding: Unicode
• Complex (Fortran)
• Rational (Scheme)
• C and C++
– Not primitive
– Use char arrays and a library of functions that
provide operations
• SNOBOL4 (a string manipulation language)
– Primitive
– Many operations, including elaborate pattern
matching
• Java
– String class
Day1: Days;
Day2: Weekday;
Day2 := Day1;
ptr = (int*)malloc(
sizeof( int))
float stuff[100];
float *p;
p = stuff;
• Arrays
– An aggregate of homogeneous data elements in
which an individual element is identified by its
position in the aggregate, relative to the first
element.
• Associative arrays
– an unordered collection of data elements that are
indexed by an equal number of values called keys
• Records
– A possibly heterogeneous aggregate of data
elements in which the individual elements are
identified by names
Copyright © 2006 Addison-Wesley. All rights reserved. 1-32
Array Types
• Operations:
– Whole array operations:
• assignment
• catenation
– elemental operations (between pairs of array
elements)
• arithmetic
– Indexing (or subscripting) is a mapping from
indices to elements
array_name (index_value_list) an element
Location (a[I,j])
= address of a [row_lb,col_lb]
+ (((I - row_lb) * n) + (j - col_lb)) *element_size