This section describes the S and T floating-point formats supported by OpenVMS Alpha systems. OpenVMS Alpha also supports the F, D, and G floating-point formats described in Section 184.108.40.206.
IEEE S_floating Format
The following PL/I types are represented using S_floating data, which occupies four contiguous bytes:
FLOAT BINARY (P) P <= 24 FLOAT DECIMAL (P) P <= 7
Bits are labeled from the right, 0 through 31, as shown in Figure 3-4.
Figure 3-4 IEEE S_floating Data Representation
The form of S_floating data is sign magnitude, with bit 31 the sign bit (0 for positive numbers, 1 for negative numbers), bits 30:23 an exponent, and bits 22:0 a normalized 24-bit fraction including the redundant most significant fraction bit not represented. The value of data is in the range 1.17549435E-38 (normalized) to 3.40282347E38. The precision is approximately one part in 2**23; that is, typically seven decimal digits.
When loaded into a 64-bit register, the S_floating value resides in bits 29-63.
IEEE T_floating Format
The following PL/I types are represented using T_floating data, which occupies eight contiguous bytes:
FLOAT BINARY (P) 24 < P <= 53 FLOAT DECIMAL (P) 7 < P <= 15
Bits are labeled from the right, 0 through 63, as shown in Figure 3-5.
Figure 3-5 IEEE T_floating Data Representation
The form of T_floating data is sign magnitude, with bit 63 the sign bit
(0 for positive numbers, 1 for negative numbers), bits 62:52 an
exponent, and bits 51:0 a normalized 53-bit fraction including the
redundant most significant fraction bit not represented. The value of
data is in the approximate range 2.225073859E-380 (normalized) to
1.797693135E308. The precision is approximately one part in 2**52; that
is, typically fifteen decimal digits.
3.2.5 Pictured Data
Use pictured data when you want to manipulate a quantity arithmetically and accept or display its value using a special format.
A picture specification (or picture) describes both the numeric attributes of a pictured variable and its input/output (I/O) format. A simple picture might look like this in a DECLARE statement:
DECLARE CREDIT PICTURE '$99999V.99DB';
This statement declares the variable CREDIT as a pictured variable. The characters within the apostrophes describe its format.
The formatting possible with pictured data is useful in many applications, but pictured data is much less efficient than fixed-point decimal data for strictly computational use.
This section discusses the following topics:
The formatting possible with pictured data is useful in many
applications, but pictured data is less efficient than fixed-point
decimal data in computations. Therefore, do not use pictured data
unless you need the formatting.
220.127.116.11 Picture Characters
Table 3-6 summarizes the PL/I picture characters, their meaning, and whether they effect numeric interpretation and internal representation. The paragraphs following the table describe the picture characters and syntax. All picture characters are shown here in uppercase, but their lowercase equivalents can be used.
|Character||Meaning||Numeric Interpretation||Internal Representation|
|V||Position of assumed decimal point||yes||no|
|9||Decimal digit, including leading zeros||yes||yes|
|Z||Decimal digit with leading-zero suppression||yes||yes|
|*||Decimal digit with asterisk for leading zero||yes||yes|
|Y||Decimal digit with space for any zero||yes||yes|
|(n)||Iteration factor for subsequent character||yes||yes|
|T||Position of digit and encoded plus sign or minus sign||yes||yes|
|I||Position of digit and encoded plus sign if number >= 0||yes||yes|
|R||Position of digit and encoded minus sign if number < 0||yes||yes|
|$||Position(s) of (drifting) dollar sign||yes||yes|
|+||Position(s) of (drifting) plus sign if number >= 0||yes||yes|
|-||Position(s) of (drifting) minus sign if number < 0||yes||yes|
|S||Position(s) of (drifting) plus sign or minus sign||yes||yes|
|,||Position at which comma is inserted||no||yes|
|.||Position at which decimal point is inserted||no||yes|
|/||Position at which slash is inserted||no||yes|
|B||Position at which space is inserted||no||yes|
|CR||Positions at which <BIT_STRING>(CR) is inserted if number < 0||no||yes|
|DB||Positions at which <BIT_STRING>(DB) is inserted if number < 0||no||yes|
Decimal Place Character (V)
The V character shows the position of the assumed decimal point, or the scale factor for the fixed-point decimal value. The V character has no effect on the internal representation of the pictured value and does not cause a decimal point to appear in the internal representation or in the output (use the period insertion character for this purpose). The following rules apply to the V character:
The following example shows the effect of the V character:
DECLARE PRICE PICTURE '$$9V.99', BAD_PRICE PICTURE '$$9.99'; PRICE = .98; /* Output as $0.98 */ BAD_PRICE = .98; /* Output as $0.00 */ PRICE = 98; /* Output as $98.00 */ BAD_PRICE = 98; /* Output as $0.98 */
In this example, note that the variable PRICE, which contains the V character, represents the value properly. The variable BAD_PRICE, which contains only the period insertion character, has an assumed V character at the end of the picture, which causes the variable to misrepresent the value.
Digit Characters (9, Z, *, Y)
The characters 9, Z, and Y, and the asterisk character (*) mark the positions occupied by decimal digits. The number of these characters present in a picture specifies the number of digits, or precision, of the fixed-point decimal value of the pictured variable. The following rules apply to these characters:
Iteration Factor (n)
You can precede any picture character that can appear more than once in a picture by an iteration factor, which must be a positive integer constant enclosed in parentheses. For example:
Encoded-Sign Characters (T, I, R)
You can use the characters T, I, and R, which are encoded-sign characters, wherever 9 is valid. Each represents a digit that has the sign of the pictured value encoded in the same position. You can use only one encoded-sign character in a picture.
An encoded-sign character cannot be used in a picture that contains one of the following characters: S, +, -, CR, or DB (described in the following text).
The meanings of the characters are:
Table 3-7 lists the encoded-sign characters and their ASCII equivalents.
|Digit||ASCII Character||Digit||ASCII Character|
Drifting Characters ($, +, -, S)
The dollar sign ($), plus sign (+), minus sign (-), and S character are drifting characters. You can use the drifting characters to indicate digits, and they also indicate a symbol to be inserted when, for example, a pictured value is written out by PUT LIST. The meanings of the characters are:
If one of these characters is used alone in the picture, it marks the position at which a special symbol or space is always inserted, and it has no effect on the value's numeric interpretation. In this case, the character must appear either before or after all characters that specify digit positions.
However, if a series of n of these characters appears, then the rightmost n-1 of the characters in the series also specify digit positions. If the digit is a leading 0, the leading 0 is suppressed, and the leftmost character drifts to the right; the character appears either in the position of the last drifting character in the series or immediately to the left of the first significant digit, whichever comes first.
Used this way, the n-1 drifting characters also define part of the numeric precision of the pictured variable, because they describe at least some of the positions occupied by decimal digits. For an example of this behavior by a drifting character (the dollar sign), refer to the V decimal place character description.
The following additional rules apply to drifting characters:
Insertion Characters (, . / B)
The insertion characters indicate that characters are inserted between digits in the pictured value. The insertion characters are the comma (,), period (.), slash (/), and the space (B). The B character indicates that a space is always inserted at the indicated position.
The drifting characters ($, +, -, S) also function as insertion characters when used singly (that is, not as part of a drifting string).
The period (.) does not imply a decimal place character V (see the example in the description of the V character, described earlier).
The following rules describe insertion by the comma, period, and slash insertion characters.
DECLARE NUM PICTURE 'ZZZV.ZZ', BAD_NUM PICTURE 'ZZZ.VZZ'; NUM=0.02; /* Output as .02 */ BAD_NUM=0.02; /* Output as 02 */
Credit (CR) and Debit (DB) Characters
These picture characters are always specified as the character pairs CR and DB. If either pair is included, it appears if the numeric value is less than zero. In each case, the associated positions contain two spaces if the numeric value is greater than or equal to 0.
The characters are inserted with the same case as used in the picture. If the lowercase form cr is used in the picture, lowercase letters are inserted in the pictured value; if the combination Cr is used, then Cr is inserted.
The credit and debit characters cannot be combined in one picture, nor can they be used in the same picture as any other character that specifies the sign of the value (S, plus sign (+), and minus sign (-) characters). In addition, they must appear to the right of all picture characters specifying digits.
After all its iterations are expanded and all its insertion characters are removed, a picture must satisfy the following syntax rules (the notation character, or ellipsis (...), indicates a series of the same character, with no embedded characters).
The character Y, T, I, or R can appear wherever 9 is valid with the following restrictions. Only one character T, I, or R can appear in a picture. A picture cannot contain T, I, or R if it also contains S, +, -, CR, or DB.
The picture specifies a signed fixed-point number with a precision of 4 (p=4) and a scale factor of 2 (q=2). The sign of the number is always included in its representation, in the first position. A period is inserted at the position of the assumed decimal point.
The picture specifies a 6-digit integer, with the first four leading zeros replaced by asterisks.
The picture specifies a fixed-point number with p=6, q=2. The first four leading zeros are replaced by asterisks in the integral portion. Both fractional digits always appear unless all six digits are 0. A period is inserted at the position of the assumed decimal point.
The picture specifies a fixed-point number with p=6, q=2. The first two digits in the integral portion are replaced with spaces if they are zeros. Two digits always appear on either side of the decimal point.
The picture specifies a fixed-point number with p=5, q=2. (The iteration factor 4 specifies a string of four S characters, one of which specifies a sign and three of which specify digits.) A plus (+) or minus (-) symbol is inserted to the immediate left of the first significant integral digit, or to the left of the decimal point if no integral digit is significant. Any insignificant integral digits are replaced with spaces or with the sign symbol.
The picture specifies a fixed-point number with p=8, q=2. If the integral portion has four or more significant digits, a comma is inserted between the third and fourth digit; otherwise, both the leading zeros and the comma are suppressed. The decimal point always appears followed by two fractional digits.
The picture specifies a fixed-point number with p=8, q=2. If the integral portion has four or more significant digits, a period is inserted between the third and fourth; otherwise, both the leading zeros and the period are suppressed. The decimal point (indicated by a comma) always appears followed by two fractional digits.
The picture specifies a fixed-point number with p=9, q=0. A slash is inserted between the 3-digit groups unless the digit preceding the slash is a suppressed 0.
The picture is invalid because a 9 occurs to the left of Z.
The picture is invalid because it contains two drifting strings (<BIT_STRING>($$$) and <BIT_STRING>(- -)).
The picture is invalid because fractional digits in this case must be pictured either with a drifting minus sign or with 9s.