NET/MASTER Network Control Language (NCL) Reference Manual

C2D
Built-in Functions
106126 Tandem Computers Incorporated 4–27
C2D The C2D built-in function converts a character string to a decimal number. The string
can be signed or unsigned.
C2D(
string
[,
n
] )
string
specifies the source data to be converted.
n
specifies an optional length for the converted value. If omitted, the string is
considered as an unsigned binary number.
If
n
is specified and the length of
string
is greater than
n
, it is truncated on the
left. If
string
is shorter than
n
, it is padded on the left with '00'x characters to the
length of
n
. The result is treated as a 2’s complement signed binary number. A 2’s
complement signed binary number is a binary number that by convention has its
most significant bit set to 1 if it is negative.
Considerations
A null string returns a null string.
When padding takes place to the left, the sign is not extended.
This function has an installation-dependent limit on the longest string that can be
handled. This limit is always at least 4 bytes.
The character string is initially interpreted as an integer, then converted to a
decimal number.
See also D2C, which converts a decimal number to an ASCII character string.
Examples
In the following example, the hexadecimal string '90'x is interpreted and converted to
an output string of “144”:
&A = '90'X
&RESULT = C2D(&A)
In the following example, the string “aaa” is converted to an output string of “97”.
The variable &B contains the length of the string to be converted:
&B = 1
&RESULT = C2D(aaa,&B)