DOC PREVIEW
UT Dallas CS 4337 - #Sebesta ch06 data type - short version cs4337

This preview shows page 1-2-3-4-5-6-39-40-41-42-43-79-80-81-82-83-84 out of 84 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Chapter 6Chapter 6 TopicsIntroductionPrimitive Data TypesPrimitive Data Types: IntegerPrimitive Data Types: Floating PointPrimitive Data Types: Complex NumberPrimitive Data Types: DecimalPrimitive Data Types: BooleanPrimitive Data Types: CharacterCharacter “String” TypesCharacter String Types OperationsCharacter String Type in Certain LanguagesCharacter String - Length OptionsCompile-Time & Run-Time DescriptorsCharacter String ImplementationUser-Defined Ordinal TypesEnumeration TypesSubrange Types .. operatorArray TypesArray Design IssuesArray IndexingArrays Index (Subscript) TypesSubscript BindingSubscript Binding and Array Categories (continued)Slide 26Slide 27Array InitializationHeterogeneous ArraysSlide 30Python – List ComprehensionArrays OperationsRectangular and Jagged ArraysSlicesSlice ExamplesImplementation of ArraysAccessing Multi-dimensioned ArraysLocating an Element in a Multi-dimensioned ArrayCompile-Time DescriptorsAssociative ArraysAssociative Arrays in PerlRecord TypesDefinition of Records in COBOLDefinition of Records in AdaReferences to RecordsOperations on RecordsImplementation of Record TypeTuple Types (heterogeneous elements)Tuple Types (continued)List TypesList Types (continued)Slide 52Slide 53Slide 54Slide 55Unions TypesDiscriminated vs. Free UnionsImplementation of UnionsPointer and Reference TypesDesign Issues of PointersPointer OperationsPointer Assignment IllustratedProblems with PointersPointers in C and C++Pointer Arithmetic in C and C++Reference TypesEvaluation of PointersRepresentations of PointersHeap ManagementReference CounterMark-Sweep for Garbage collectionSlide 72Marking AlgorithmVariable-Size CellsType CheckingType Checking (continued)Strong TypingStrong Typing (continued)Name Type EquivalenceStructure Type EquivalenceType Equivalence (continued)Theory and Data TypesTheory and Data Types (continued)Java Garbage CollectionChapter 6Data TypesCopyright © 2012 Addison-Wesley. All rights reserved. 1-2Chapter 6 Topics•Introduction•Primitive Data Types•Character String Types•User-Defined Ordinal Types•Array Types•Associative Arrays•Record Types•Tuple Types•List Types•Union Types•Pointer and Reference Types•Type Checking•Strong Typing•Type Equivalence•Theory and Data TypesCopyright © 2012 Addison-Wesley. All rights reserved. 1-3Introduction•A Data type defines a collection of data objects and a set of predefined operations on those objects•A Descriptor is the collection of the attributes of a variable•An Object represents an instance of a user-defined (abstract data) type•One design issue for all data types: What operations are defined? How are they specified?Copyright © 2012 Addison-Wesley. All rights reserved. 1-4Primitive Data Types•Almost all programming languages provide a set of primitive data types•Primitive data types: Those not defined in terms of other data types•Some primitive data types are merely reflections of the hardware•Others require only a little non-hardware support for their implementationCopyright © 2012 Addison-Wesley. All rights reserved. 1-5Primitive Data Types: Integer•Almost always an exact reflection of the hardware so the mapping is trivial•There may be as many as eight different integer types in a language •Java’s signed integer sizes: byte, short, int, longCopyright © 2012 Addison-Wesley. All rights reserved. 1-6Primitive Data Types: Floating Point•Model real numbers, but only as approximations•Languages for scientific use support at least two floating-point types (e.g., float and double; sometimes more•Usually exactly like the hardware, but not always•IEEE Floating-PointStandard 754Copyright © 2012 Addison-Wesley. All rights reserved. 1-7Primitive Data Types: Complex Number•Some languages support a complex type, e.g., C99, Fortran, and Python•Each value consists of two floats, the real part and the imaginary part•Literal form (in Python): (7 + 3j), where 7 is the real part and 3 is the imaginary part•In Lisp: #C(7, 3)Copyright © 2012 Addison-Wesley. All rights reserved. 1-8Primitive Data Types: Decimal•For business applications (money)–Essential to COBOL•Using 4 bits as a nibble. So 1 byte for 2 decimal digits–C# offers a decimal data type•Store a fixed number of decimal digits, in coded form (BCD)•Using 1 byte for a digit where4 bits for a decimal digit, and 4 bits for sign•Advantage: accuracyCopyright © 2012 Addison-Wesley. All rights reserved. 1-9Primitive Data Types: Boolean•Simplest of all•Range of values: two elements, one for “true” and one for “false”•Could be implemented as bits, but often as bytes–Advantage: readabilityCopyright © 2012 Addison-Wesley. All rights reserved. 1-10Primitive Data Types: Character•Stored as numeric coding•Most commonly used coding: ASCII•An alternative, 16-bit coding: Unicode (UCS-2)–Includes characters from most natural languages–Originally used in Java–C# and JavaScript also support Unicode•32-bit Unicode (UCS-4)–Supported by Fortran, starting with 2003Copyright © 2012 Addison-Wesley. All rights reserved. 1-11Character “String” Types •Values are sequences of characters•Design issues:–Is it a primitive type or just a special kind of array?–Should the length of strings be static or dynamic?Copyright © 2012 Addison-Wesley. All rights reserved. 1-12Character String Types Operations•Typical operations:–Assignment and copying–Comparison (=, >, etc.) –Concatenation–Substring reference–Pattern matchingCopyright © 2012 Addison-Wesley. All rights reserved. 1-13Character String Type in Certain Languages•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•Fortran and Python–Primitive type with assignment and several operations•Java–Primitive via the String class•Perl, JavaScript, Ruby, and PHP - Provide built-in pattern matching, using regular expressionsCopyright © 2012 Addison-Wesley. All rights reserved. 1-14Character String - Length Options1. Static: COBOL, Java’s String class2. Limited Dynamic Length: C and C++In these languages, a special character is used to indicate the end of a string’s characters, rather than maintaining the length3. Dynamic (no maximum): SNOBOL4, Perl, JavaScript•Ada supports all three string length optionsCopyright © 2012


View Full Document

UT Dallas CS 4337 - #Sebesta ch06 data type - short version cs4337

Download #Sebesta ch06 data type - short version cs4337
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view #Sebesta ch06 data type - short version cs4337 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view #Sebesta ch06 data type - short version cs4337 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?