Download
slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
DATA TYPES PowerPoint Presentation

DATA TYPES

167 Vues Download Presentation
Télécharger la présentation

DATA TYPES

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. DATA TYPES

  2. Numeric Data Types • integer • floating point numbers • fixed point real numbers • boolean • character

  3. Numeric Data Types • integer • operations: arithmetic, relational, and bit operations, assignment s magnitude 1 bit 15 bits

  4. Numeric Data Types • floating point real numbers • representation limitations (precision) S exponent mantissa 1 bit 8 bits 23 bits

  5. Numeric Data Types • fixed point real numbers • precise representation within a restricted range • stored much like character strings using BCD • (1 or 2 digits / byte) • hardware supported or software simulated

  6. Numeric Data Types • booleans • may address a single bit or an entire storage unit (byte, word) C++: bool (true, false) Pascal: boolean (true, false) C: no boolean type (0=false)

  7. Numeric Data Types • character • most use ASCII representation which uses values 0-127 to encode each of 128 characters • Java uses 16 bit Unicode for international alphabets • represented by underlying hardware character set and support relational operations

  8. ASCII Character Table 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI 1 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 2 SP ! " # $ % & ' ( ) * + , - . / 3 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 4 @ A B C D E F G H I J K L M N O 5 P Q R S T U V W X Y Z [ \ ] ^ _ 6 ` a b c d e f g h i j k l m n o 7 p q r s t u v w x y z { | } ~ DEL

  9. Character String Types • Design Issues: • static or dynamic length? • primitive type or character array with special properties? • operators or library functions?

  10. Character String Types • Length options: • static - length is fixed at compile time to the declared length • limited length dynamic - maximum length is specified in the static declaration of the string variable • dynamic length with no maximum

  11. Character String Types • Length options: • static - • FORTRAN 77, Pascal • limited length dynamic - • C/C++ using arrays of characters • dynamic length with no maximum - • SNOBOL4, Perl, C++ string class, Java

  12. Character String Types • String operations: • assignment, comparison, concatenation, substring extraction • implemented with operator symbols or library functions

  13. Character String Types • String operations: • C character arrays: C++ string class: • assignment strcpy(s1,s2) = • comparison strcmp(s1,s2) ==, !=, <, >, >=, <= • concatenation strcat (s1,s2) + • substring strstr(s1,s2) substr(start, len)

  14. Character String Types • Implementation of string types: • software used for storage, retrieval and manipulation or directly supported in hardware • compile time or run time descriptors

  15. Descriptors A descriptor stores the necessary attributes of a variable. It is used for type checking, and memory allocation and deallocation. Static descriptors are are built by the compiler, as a part of the symbol table and are not required after compilation For dynamic attributes the descriptor is maintained during execution.

  16. Character String Types Compile time descriptor: Type (static string) Length Address

  17. Character String Types Run time descriptor: Type (limited dynamic string) Maximum Length Current Length Address

  18. Character String Types Run time descriptor: Type (dynamic string) Current Length Address