Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

Source-to-target rules

Target: Coded Arithmetic

Source:

FIXED BINARY, FIXED DECIMAL,
FLOAT BINARY, and FLOAT DECIMAL
These are all coded arithmetic data. Rules for conversion between them are given under each data type taken as a target.
Arithmetic character PICTURE
Data first converts to decimal with scale and precision determined by the corresponding PICTURE specification. The decimal value then converts to the base, scale, mode, and precision of the target. See the specific target types of coded arithmetic data using FIXED DECIMAL or FLOAT DECIMAL as the source.
CHARACTER
The source string must represent a valid arithmetic constant or complex expression; otherwise, the CONVERSION condition is raised. The constant can be preceded by a sign and can be surrounded by blanks. The constant cannot contain blanks between the sign and the constant, or between the end of the real part and the sign preceding the imaginary part of a complex expression.

The constant has base, scale, mode, and precision attributes. It converts to the attributes of the target when they are independent of the source attributes, as in the case of assignment. See the specific target types of coded arithmetic data using the attributes of the constant as the source.

If an intermediate result is necessary, as in evaluation of an operational expression, the attributes of the intermediate result are the same as if a decimal fixed-point value of precision (N,0) had appeared in place of the string. (This allows the compiler to generate code to handle all cases, regardless of the attributes of the contained constant.) Consequently, any fractional portion of the constant might be lost. See the specific target types of coded arithmetic data using FIXED DECIMAL as the source.

It is possible that during the initial conversion of the character data item to an intermediate fixed decimal number, the value might exceed the default size of the intermediate result. If this occurs, the SIZE condition is raised if it is enabled.

If a character string representing a complex number is assigned to a real target, the complex part of the string is not checked for valid arithmetic characters and CONVERSION cannot be raised, since only the real part of the string is assigned to the target.

If the source is a null string or a string of one or more blanks, the target will be assigned the value zero. The CONVERSION condition will not be raised.

BIT
If the conversion occurs during evaluation of an operational expression, the source bit string is converted to an unsigned value that is FIXED BINARY(M,0). See the specific target types of coded arithmetic data using FIXED BINARY as the source.

If the source string is longer than the allowable precision, bits on the left are ignored. If nonzero bits are lost, the SIZE condition is raised.

A null string gives the value zero.

GRAPHIC
Graphic variables and strings are converted to CHARACTER, and then follow the rules for character source described
WIDECHAR
Widechar variables and strings are converted to CHARACTER, and then follow the rules for character source described in ***.
Target: FIXED BINARY (p2,q2)

Source:

FIXED DECIMAL (p1,q1)
The precision of the result is p2 = min(M,1+CEIL(p1*3.32)) and q2=CEIL(ABS(q1*3.32))*SIGN(q1).
FLOAT BINARY (p1)
The precision conversion is as described under Converting arithmetic precision with p1 as declared or indicated and q1 as indicated by the binary point position and modified by the value of the exponent.
FLOAT DECIMAL (p1)
The precision conversion is the same as for FIXED DECIMAL to FIXED BINARY with p1 as declared or indicated and q1 as indicated by the decimal point position and modified by the value of the exponent.
Arithmetic character PICTURE
See Target: Coded Arithmetic.
CHARACTER
See Target: Coded Arithmetic.
BIT
See Target: Coded Arithmetic.
GRAPHIC
See Target: Coded Arithmetic.
WIDECHAR
See Target: Coded Arithmetic.
Target: FIXED DECIMAL (p2,q2)

Source:

FIXED BINARY (p1,q1)
The precision of the result is p2=1+CEIL(p1/3.32) and q2=CEIL(ABS(q1/3.32))*SIGN(q1).
FLOAT BINARY (p1)
The precision conversion is the same as for FIXED BINARY to FIXED DECIMAL with p1 as declared or indicated and q1 as indicated by the binary point position and modified by the value of the exponent.
FLOAT DECIMAL (p1)
The precision conversion is as described under Converting arithmetic precision with p1 as declared or indicated and q1 as indicated by the decimal point position and modified by the value of the exponent.
Arithmetic character PICTURE
See Target: Coded Arithmetic.
CHARACTER
See Target: Coded Arithmetic.
BIT
See Target: Coded Arithmetic.
GRAPHIC
See Target: Coded Arithmetic.
WIDECHAR
See Target: Coded Arithmetic.
Target: FLOAT BINARY (p2)

Source:

FIXED BINARY (p1,q1)
The precision of the result is p2=p1. The exponent indicates any fractional part of the value.
FIXED DECIMAL (p1,q1)
The precision of the result is p2=CEIL(p1*3.32). The exponent indicates any fractional part of the value.
FLOAT DECIMAL (p1)
The precision of the result is p2=CEIL(p1*3.32).
Arithmetic character PICTURE
See Target: Coded Arithmetic.
CHARACTER
See Target: Coded Arithmetic.
BIT
See Target: Coded Arithmetic.
GRAPHIC
See Target: Coded Arithmetic.
WIDECHAR
See Target: Coded Arithmetic.
Target: FLOAT DECIMAL (p2)

Source:

FIXED BINARY (p1,q1)
The precision of the result is p2=CEIL(p1/3.32). The exponent indicates any fractional part of the value.
FIXED DECIMAL (p1,q1)
The precision of the result is p2=p1. The exponent indicates any fractional part of the value.
FLOAT BINARY (p1)
The precision of the result is p2=CEIL(p1/3.32).
Arithmetic character PICTURE
See Target: Coded Arithmetic.
CHARACTER
See Target: Coded Arithmetic.
BIT
See Target: Coded Arithmetic.
GRAPHIC
See Target: Coded Arithmetic.
WIDECHAR
See Target: Coded Arithmetic.
Target: Arithmetic character PICTURE

The arithmetic character PICTURE data item is the character representation of a decimal fixed-point or floating-point value. The following descriptions for source to arithmetic character PICTURE target show those target attributes that allow assignment without loss of leftmost or rightmost digits.

Source:

FIXED BINARY (p1,q1)
The target must imply:
  fixed decimal (1+x+q-y,q) or
  float decimal (x)

where x>=CEIL(p1/3.32), y=CEIL(q1/3.32), and q>=y.

FIXED DECIMAL (p1,q1)
The target must imply:
  fixed decimal (x+q-q1,q) or
  float decimal (x)

where x>=p1 and q>=q1.

FLOAT BINARY (p1)
The target must imply:
  fixed decimal (p,q) or
  float decimal (p)

where p>=CEIL(p1/3.32) and the values of p and q take account of the range of values that can be held by the exponent of the source.

FLOAT DECIMAL (p1)
The target must imply:
  fixed decimal (p,q) or
  float decimal (p)

where p>= p1 and the values of p and q take account of the range of values that can be held by the exponent of the source.

Arithmetic character PICTURE
The implied attributes of the source will be either FIXED DECIMAL or FLOAT DECIMAL. See the respective entries for this target.
CHARACTER
See Target: Coded Arithmetic.
BIT(n)
The target must imply:
  fixed decimal (1+x+q,q) or
  float decimal (x)

where x>=ceil(n/3.32) and q>=0.

GRAPHIC
See Target: Coded Arithmetic.
WIDECHAR
See Target: Coded Arithmetic.
Target: CHARACTER

Source:

FIXED BINARY, FIXED DECIMAL,
FLOAT BINARY, and FLOAT DECIMAL
The coded arithmetic value is converted to a decimal constant (preceded by a minus sign if it is negative) as described below. The constant is inserted into an intermediate character string whose length is derived from the attributes of the source. The intermediate string is assigned to the target according to the rules for string assignment.

The rules for coded-arithmetic-to-character-string conversion are also used for list-directed and data-directed output, and for evaluating keys (even for REGIONAL files).

FIXED BINARY (p1,q1)
The binary precision (p1,q1) is first converted to the equivalent decimal precision (p,q), where p=1+CEIL(p1/3.32) and q=CEIL(ABS(q1/3.32))*SIGN(q1). Thereafter, the rules are the same as for FIXED DECIMAL to CHARACTER.
FIXED DECIMAL (p1,q1)
If p1>=q1>=0 then:

If p1<q1 or q1<0, a scaling factor appends to the right of the constant; the constant is an optionally-signed integer. The scaling factor appears even if the value of the item is zero and has the following syntax:

  F{+|-}nn

where {+|-}nn has the value of -q1.

The length of the intermediate string is p1+k+3, where k is the number of digits necessary to hold the value of q1 (not including the sign or the letter F).

If the arithmetic value is complex, the intermediate string consists of the imaginary part concatenated to the real part. The left-hand, or real, part is generated as a real source. The right-hand, or imaginary, part is always signed, and it has the letter I appended. The generated string is a complex expression with no blanks between its elements. The length of the intermediate string is:

  2*p1+7     for p1>=q1>=0
  2*(p1+k)+7 for p1<q1 or q1<0

The following examples show the intermediate strings that are generated from several real and complex fixed-point decimal values:

Precision     Value     String
 
(5,0)       2947        'bbbb2947'
(4,1)       -121.7      'b-121.7'
(4,-3)      -3279000    '-3279F+3'
(2,1)       1.2+0.3I    'bbb1.2+0.3I'
FLOAT BINARY (p1)
The floating-point binary precision (p1) first converts to the equivalent floating-point decimal precision (p), where p=CEIL(p1/3.32). Thereafter, the rules are the same as for FLOAT DECIMAL to CHARACTER.
FLOAT DECIMAL (p1)
A decimal floating-point source converts as if it were transmitted by an E-format item of the form E(w,d,s) where:
  w, the length of the intermediate string, is p1+8.

  d, the number of fractional digits, is p1-1.

  s, the number of significant digits, is p1.

If the arithmetic value is complex, the intermediate string consists of the imaginary part concatenated to the real part. The left-hand, or real, part is generated as a real source. The right-hand, or imaginary, part is always signed, and it has the letter I appended. The generated string is a complex expression with no blanks between its elements. The length of the intermediate string is 2*p+17.

The following examples show the intermediate strings that are generated from several real and complex floating-point decimal values:

Precision    Value          String
 
(5)          1735*10**5     'b1.7350E+0008'
(5)          -.001663       '-1.6630E-0003'
(3)          1              'b1.00E+0000'
(5)          17.3+1.5I      'b1.7300E+0001+1.5000E+0000I'
Arithmetic character PICTURE
A real arithmetic character field is interpreted as a character string and assigned to the target string according to the rules for converting string lengths. If the arithmetic character field is complex, the real and imaginary parts are concatenated before assignment to the target string. Insertion characters are included in the target string.
BIT
Bit 0 becomes the character 0 and bit 1 becomes the character 1. A null bit string becomes a null character string. The generated character string is assigned to the target string according to the rules for converting string lengths.
GRAPHIC
DBCS to SBCS conversion is possible only if there is a corresponding SBCS character. Otherwise, the CONVERSION condition is raised.
WIDECHAR
Conversion from widechar to character is performed only if all the widechars have a value less than '0080'wx. Otherwise, the CONVERSION condition is raised.

Target: BIT

Source:

FIXED BINARY, FIXED DECIMAL,
FLOAT BINARY, and FLOAT DECIMAL
If necessary, the arithmetic value converts to binary and both the sign and any fractional part are ignored. (If the arithmetic value is complex, the imaginary part is also ignored.) The resulting binary value is treated as a bit string. It is assigned to the target according to the rules for string assignments.
FIXED BINARY (p1,q1)
The length of the intermediate bit string is given by:
  min(M,(p1-q1))

If (p1-q1) is negative or zero, the result is a null bit string.

The following examples show the intermediate strings that are generated from several fixed-point binary values:

Precision   Value    String
 
(1)           1      '1'B
(3)          -3      '011'B
(4,2)       1.25     '01'B
FIXED DECIMAL (p1,q1)
The length of the intermediate bit string is given by:
  min(M,CEIL((p1-q1)*3.32))

If (p1-q1) is negative or zero, the result is a null bit string.

The following examples show the intermediate strings that are generated from several fixed-point decimal values:

Precision   Value    String
 
(1)           1         '0001'B
(2,1)       1.1        '0001'B
FLOAT BINARY (p1)
The length of the intermediate bit string is given by:
  min(M,p1)
FLOAT DECIMAL (p1)
The length of the intermediate bit string is given by:
  min(M,ceil(p1*3.32))
Arithmetic character PICTURE
Data is first interpreted as decimal with scale and precision determined by the corresponding PICTURE specification. The item then converts according to the rules given for FIXED DECIMAL or FLOAT DECIMAL to BIT.
CHARACTER
Character 0 becomes bit 0 and character 1 becomes bit 1. Any character other than 0 or 1 raises the CONVERSION condition. A null string becomes a null bit string. The generated bit string, which has the same length as the source character string, is assigned to the target according to the rules for string assignment.
GRAPHIC
Graphic 0 becomes bit 0 and graphic 1 becomes bit 1. Any graphic other than 0 or 1 raises the CONVERSION condition. A null string becomes a null bit string. The generated bit string, which has the same length as the source graphic string, is then assigned to the target according to the rules for string assignment.
WIDECHAR
Widechar 0 ('0030'wx) becomes bit 0 and widechar 1 ( '0031'wx) becomes bit 1. Any widechar other than 0 or 1 raises the CONVERSION condition. A null string becomes a null bit string. The generated bit string, which has the same length as the source widechar string, is then assigned to the target according to the rules for string assignment.
Target: GRAPHIC

Nongraphic source is first converted to character according to the rules in Target: Character. The resultant character string is then converted to a DBCS string.

Target: WIDECHAR

Source other than widechar is first converted to character according to the rules in Target: Character. The resultant character string is then converted to a widechar string.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)