Types of Data


The ultimate purpose of every program is to create and manipulate data. The collective term data refers to all the information available to, or generated by, a program. This data is composed of individual data items, each of which can be manipulated separately from the rest. In DCL, a data item has an associated data type, which signifies what kind of data it is. Strictly speaking, DCL supports two types of data: integers and character strings. However, a 24 Symbols, Data, and Expressions particularly useful third type of data, Boolean data, can be implemented with the first two. The following sections discuss these data types.

Every data item has two representations, an internal one and an external one. The internal representation is determined by the host computer, which for DCL is the OpenVMS VAX or Alpha system. Almost all computers operate in binary, representing data items as numbers in base 2. Each binary digit is called a bit, so we speak in terms of data occupying a certain number of bits of computer memory.

Computer users are much happier when data can be represented in natural forms such as decimal numbers or letters of the alphabet. These familiar forms are the external representations of the data, and all programming languages provide for them. When the external representation of a data item appears in a program, it is called a literal. The following DCL command contains two literals:

     $ write sys$output "The answer is ", 13 

The first literal is the character string "The answer is" and the second is the decimal integer 13.

Integers

An integer is a whole number, which can be negative, zero, or positive. DCL supports signed integers that occupy 32 bits of memory, thus restricting them to the range from -2,147,483,648 to +2,147,483,647. In the VAX and Alpha architectures, a 32-bit quantity is referred to as a longword. Although the internal representation of an integer is in binary, the external representation is made up of digits and other characters, which allows a "natural" specification of the number.

Integer literals can be represented in base 10 (decimal), base 16 (hexadecimal), or base 8 (octal). Decimal integers are discussed in this section, and hexadecimal integers in Appendix A. Octal integers are rarely used and will not be discussed in this book. A decimal integer is composed of the ten decimal digits 0-9, optionally preceded by a plus sign (+) or minus (-). Punctuation marks such as commas are not allowed in integers. The following are examples of decimal integers:

     0 7 07 42 +3286 1 -39840938 

Character Strings

A character string is a sequence of individual characters. A character can be an actual glyph, such as an uppercase A or a plus sign (+). Glyphs are usually called printable characters. A character can also be a control character, which does not represent a glyph but rather a formatting operation, such as tab or line feed. Each distinct character is assigned a code number, and the complete collection of characters and their code numbers is called a character set. The VAX and Alpha architectures employ the ASCII character set (ASCII stands for American Standard Code for Information Interchange) subset of the ISO Latin 1 character set. In both ISO Latin 1 and in ASCII, the characters occupy eight bits and the code numbers range from 0 to 255.

The number of individual characters in a character string is called its length. A character string can be composed of any number of characters from 1 to approximately 900. The upper limit depends on the context in which the string is used. A character string can also contain no characters at all, in which case it is called the null string.

A character string literal is represented by enclosing its constituent characters in a set of double quotes ("). Here are a few examples:

     "" "X" "X" "*" a short string"     "This is a sentence complete with punctuation." 

The first example is the null string. You can represent any printable character in a string literal, but there is no way to represent control characters. A special case is made of the double quote character: you must represent each double quote character in the literal with an adjacent pair of double quotes:

     "This string contains ""a quoted phrase""." 

The string literal shown here consists of six words, the last three of which are inside double quotes. Each double quote that is part of the literal, but not the ones that enclose the literal, must be paired. It is a common mistake to forget to pair the double quotes inside a string:

     "This string contains "a quoted phrase"." 

It appears to DCL that the string literal ends with the space following the word contains and that the final three words are not part of the string literal.




Getting Started with OpenVMS System Management
Getting Started with OpenVMS System Management (HP Technologies)
ISBN: 1555582818
EAN: 2147483647
Year: 2004
Pages: 130
Authors: David Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net