z/OS TSO/E REXX Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


C2D (Character to Decimal)

z/OS TSO/E REXX Reference
SA32-0972-00

Read syntax diagramSkip visual syntax diagram
>>-C2D(string--+----+--)---------------------------------------><
               '-,n-'      

returns the decimal value of the binary representation of string. If the result cannot be expressed as a whole number, an error results. That is, the result must not have more digits than the current setting of NUMERIC DIGITS.

If string is null, returns 0.

Here are some examples:
C2D('09'X)      ->        9
C2D('81'X)      ->      129
C2D('FF81'X)    ->    65409
C2D('')         ->        0
C2D('a')        ->      129     /*  EBCDIC  */

If you specify n, the string is taken as a signed number expressed in n characters. The number is positive if the leftmost bit is off, and negative, in two's complement notation, if the leftmost bit is on. In both cases, it is converted to a whole number, which may, therefore, be negative. The string is padded on the left with '00'x characters (note, not “sign-extended”), or truncated on the left to n characters. This padding or truncation is as though RIGHT(string,n,'00'x) had been processed. If n is 0, C2D always returns 0. If you do not specify n, string is processed as an unsigned binary number.

Here are some examples:
C2D('81'X,1)      ->     -127
C2D('81'X,2)      ->      129
C2D('FF81'X,2)    ->     -127
C2D('FF81'X,1)    ->     -127
C2D('FF7F'X,1)    ->      127
C2D('F081'X,2)    ->    -3967
C2D('F081'X,1)    ->     -127
C2D('0031'X,0)    ->        0

Implementation maximum: The input string cannot have more than 250 characters that are significant in forming the final result. Leading sign characters ('00'x and 'FF'x) do not count toward this total.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014