Introduction

Each arithmetic, pictured, or string value can be converted to another value whose data type is any other arithmetic, pictured, or string data type. Conversion is not possible for data other than arithmetic, pictured, or string data.

Conversions occur as a result of using the assignment, arithmetic, relational, or concatenate operators; from the use of certain built-in functions; from GET/ PUT statements during parameter passing; and from statement options such as KEY and KEYFROM.

Each conversion begins with a source value to be converted and a complete or partial data type called the target data type. The target data type is determined by the context that caused the conversion. For example, the data type of the variable on the left side of the assignment operator provides the target data type for the conversion that is to be performed for that assignment. A partial target data type may result from the use of a conversion built-in function such as FIXED, FLOAT, BINARY, DECIMAL, BIT, or CHARACTER, as well as from other contexts, such as the use of arithmetic operators.

The conversion rules described in the section Arithmetic Operators define the target data type for conversions that result from arithmetic or relational operators. The section The Concatenate Operator gives the target data type for conversions that result from using the concatenate operator. Conversion between pointers and offsets is discussed in the section Locator Data.

When Widechar is converted to Graphic, the Widechar source value is first converted to Character, and then the intermediate Character value is converted to Graphic. For other Widechar conversions, Widechar is first converted to Character, and then the Character string conversions in the following table apply.

When Graphic is converted to Widechar, the Graphic source value is first converted to Character, and then the intermediate Character value is converted to Widechar. For other Graphic conversions, the Graphic source value is first converted to Character, and then the Character string conversions in the following table apply.

The following table shows the specific conversions described in this chapter.

Data Type     Conversion
Arithmetic Arithmetic to Arithmetic

Arithmetic to Bit string

Arithmetic to Character string

String Bit string to Arithmetic

Bit string to Character string

Character string to Arithmetic

Character string to Bit string

Format Controlled

Pictured Pictured to Arithmetic

Pictured to Bit string

Pictured to Character string

Conversion to Pictured Data

The CEIL function used in many of the conversion rules gives the smallest integer that is greater than or equal to the function's argument. For example,

CEIL(1.1)

produces the value two.