Data conversions


Understanding the data conversion that can be performed on an expression is necessary for achieving desired results in your output file. BMC recommends that you make both the operands the same data-type. When necessary, a data conversion will be performed automatically for an operand in order to modify its data-type, size and/or precision.

Related topic

Data-type

Type conversion is the process of changing the general data-type of an operand from one form to another. For example, an operand in zoned decimal type (Z) will be converted into packed decimal type (P) in order to perform a numeric operation such as addition. Changing an operand from one format to another does not change its logical value.

Size

When an operand is converted from one data-type to another, it is normal for its size (length in bytes) to change. As a general rule, the size of the converted target operand will be the minimum size necessary to hold the value from original (source) operand. For example, when converting an operand from 5Z (5-byte zoned decimal) into packed decimal, the converted target value will be 3P (3-byte packed decimal).

Increasing the size of an operand without changing its data-type will not cause any data loss. For numeric operands (data-type F, P, or Z), this process appends leading zeroes as necessary; the value and significance is not affected. For fixed-length string (C) operands, this process appends trailing blanks as necessary.

Decreasing the size of an operand without changing its data type might cause a loss of data. For numeric operands, the process is performed by removing leading zeroes as necessary; an overflow exception is recognized if the value is too large for the reduced size. For character string operands (data-type ‘C’), the process is performed by removing trailing characters as necessary. If non-blank characters are removed, the value of the converted operand is not the same as the original.

The following table provides detailed information about the size of an operand when converting from one type to another:

Target data-type /Source data-type

C

F

P

X

Z

C

-- 1

8

8

8

none 2

F

* 3

-- 1

(a) 4

P 5

P

* 3

Source Size

Target Size

-- 1

Source Size

Target Size

(a * 2 - 1)

1

1

1

1


2

2

2

2


3-5

4

3-5

4


6+

8

6+

8


X

* 3

(a) 4

-- 1

P 5

Z

* 3

P 5

(a / 2)+1

P 5

-- 1

1Denotes same data-type; no conversion exposure exists.

2 Invalid conversion.

3This conversion cannot occur unless the length of the resulting target character string is specified explicitly.

4Length of source operand.

5Intermediate conversion to type P is performed.

The following table refers to cells in the ‘P’ column of Size of operand after conversion where the size of the converted target data is dependent of the size of the source.

Size of target (source type=F or X; target type=P)

Size of source

Size of target

1

2

2

3

3

5

4

6

5

7

6

8

7

9

8

11

Precision

Precision is defined as the number of significant decimal digits to the right of an assumed decimal point. n general, the precision is unaffected by changes to the data-type or size of an operand. However, the precision of an operand will be changed under certain conditions. Increasing the precision of an operand has no effect on its value; in general, the size of the operand must also be increased simultaneously. Decreasing the precision of an operand might cause a loss of precise value as fractional digits are eliminated, because the product will round the value of the operand when its precision is reduced.

For example, increasing the precision has no effect in the following example:

     :5.4Z := 6:4.2Z

because 000456.1800 is equal to 0456.18.

Decreasing the precision (rounding) could cause loss of precise value, as shown in the following example:

     :4.2Z := 6:5.4Z

where rounding .1783 to .18 might not be acceptable.


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

Fast Path/EP products reference information 4.1