HP OpenVMS Systems Documentation | 
	
HP COBOL
 | 
	
| Previous | Contents | Index | 
A function-name is the name of a function as shown in
Table 7-1, Intrinsic Functions. Note that function-names are not reserved words and may
appear in a different context in a program as a user-defined word or a
system-name.
1.2.2 Literals
A literal is a character-string whose value is specified by: (1) the ordered set of characters it contains, or (2) a reserved word that is a figurative constant.
HP COBOL provides two types of literals: numeric and nonnumeric.
Numeric literals include floating-point literals and nonnumeric
literals include hexadecimal and national literals. Floating-point,
hexadecimal, and national literals are Hewlett-Packard extensions. The
following two sections describe literals in detail.
1.2.2.1 Numeric Literals
A numeric literal is a character string of 1 to 33 characters on Alpha and I64 or 1 to 20 characters on VAX, selected from the digits 0 to 9, the plus sign (+), the minus sign (-), and the decimal point (.).
The value of a numeric literal is the algebraic quantity represented by the characters in the literal.
Table 1-4 provides examples of numeric literals.
| Literal | Value | 
|---|---|
| 12 | 12 | 
| 0.12000 | 0.12 | 
| -123456789012345678 | -123456789012345678 | 
| 000000003 | 3 | 
| -34.455445555 | -34.455445555 | 
| 0 | 0 | 
| +0.000000000001 | +0.000000000001 | 
| +0000000000001 | +1 | 
A floating-point literal, a Hewlett-Packard extension to numeric literals, is a character-string whose value is specified by 4 to 37 characters on Alpha and I64 or 4 to 24 characters on VAX, selected from the digits 0 to 9, the plus sign (+), the minus sign (-), the decimal point (.), and the letter E (uppercase or lowercase).
You can use floating-point literals to achieve a wider range of numeric literal values.
The value of a floating-point literal is the algebraic quantity
represented by the characters in the literal that precede the E
multiplied by ten raised to the power of the algebraic quantity
represented by the characters in the literal following
 the E.
Table 1-5 provides a few examples of floating-point literals.
| Literal | Value | 
|---|---|
| 1.6e5 | 160000.0 | 
| 3.2E-3 | 0.0032 | 
| -1.e4 | -10000.0 | 
| 0.002e+6 | 2000.0 | 
| -.8E-2 | -0.008 | 
A nonnumeric literal is a character-string of 0 to 256 characters. It is delimited on both ends by quotation marks (") or apostrophes ('). A nonnumeric literal delimited by apostrophes is treated in the same manner as a nonnumeric literal delimited by quotation marks.
The value of a nonnumeric literal is the value of the characters in the character-string. It does not include the quotation marks (or apostrophes) that delimit the character-string. All other punctuation characters in the nonnumeric literal are part of its value.
The compiler truncates nonnumeric literals to a maximum of 256 characters.
Table 1-6 provides examples of nonnumeric literals. In these examples, s represents a space character.
| Literal | Value | 
|---|---|
| "ABC" | ABC | 
| "01" | 01 | 
| "s01" | s01 | 
| "D""E""F" | D"E"F | 
| "a.b" | a.b | 
| 'GHI' | GHI | 
| '02' | 02 | 
| 's02' | s02 | 
| 'c.d' | c.d | 
| """" | " | 
| '""' | "" | 
| '''' | ' | 
| "''" | '' | 
| 'J""K' | J""K | 
| "J""""K" | J""K | 
| 'J''''K' | J''K | 
| "J''K" | J''K | 
| 'L''M''N' | L'M'N | 
| "L'M'N" | L'M'N | 
| 'O"P"Q' | O"P"Q | 
| "O""P""Q" | O"P"Q | 
| 'R""S""T' | R""S""T | 
| "R""""S""""T" | R""S""T | 
| 'U''''V''''W' | U''V''W | 
| "U''V''W" | U''V''W | 
A hexadecimal literal (a Hewlett-Packard extension to nonnumeric literals) is a character string of 2 to 256 hexadecimal digits. On the left it is delimited by the separator X (or x) immediately followed by a quotation mark (") or apostrophe ('); on the right it is delimited by a matching quotation mark or apostrophe. For example:
| Previous | Next | Contents | Index |