Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

X-LITERAL-TO-INTEGER( ) Convert string to integer

&pagelevel(3)&pagelevel

Domain: Conversion functions

The X-LITERAL-TO-INTEGER( ) function converts a string which is up to 4 bytes long to an integer. The input string can be specified as an X string or as a C string. An empty string is assigned the value 0.

If the input string consists of less than 4 characters, it is padded from left to right with X’00’.

X-LITERAL-TO-INTEGER( ) is the inverse function to INTEGER-TO-X-LITERAL( ).

Format

X-LITERAL-TO-INTEGER( )

X-LIT-TO-INT( )

STRING = string_expression

Result type

INTEGER

Input parameters

STRING = string_expression
Specifies the string up to 4 characters in length which is to be converted.

Result

Integer value

0
The string contains an empty string.

Error message

SDP0403   SPECIFIED STRING IS TOO LONG (MORE THAN 4 CHARACTERS)

Example

/DECLARE-VARIABLE A( TYPE= *INTEGER )
/A = X-LIT-TO-INT( X'F1F2F3F4' )
/SHOW-VARIABLE A
A = -235736076
/A = X-LIT-TO-INT( C'/ $*' )
/SHOW-VARIABLE A
A = 1631607644
/A = X-LIT-TO-INT( C'' )
/SHOW-VARIABLE A
A = 0
/A = X-LIT-TO-INT( X'' )
/SHOW-VARIABLE A
A = 0
/A = X-LIT-TO-INT( X'00' )
/SHOW-VARIABLE A
A = 0