15 UNICODENUMBER PIC S9(11)V9(04) USAGE NATIONAL SIGN IS LEADING, SEPARATE.
The sysLib.convertNumberToUnicodeNum() system function converts the digits of a source numeric value into UNICODE characters preceded by a UNICODE sign character. Leading zeros are included for the integer part, trailing zeros are included for the fractional part, and no decimal character is included.
sysLib.convertNumberToUnicodeNum( source SMALLINT | INT | BIGINT | DECIMAL in, target UNICODE out] )
The required length of the UNICODE variable depends on the data type specification of the numeric field and whether the conversion is signed or unsigned. Validation ensures that you use the required lengths. Note that for NUM and DECIMAL, both odd and even lengths are promoted to the next highest even length when performing a signed conversion. In this way, converting a NUM(10) or NUM(11) variable to a UNICODE variable with a sign requires a UNICODE(12) variable.
Numeric data type | UNICODE num length (signed conversion) | UNICODE num length (unsigned conversion) |
---|---|---|
SMALLINT, BIN(4,x) | 6 | 5 |
INT, BIN(9,x) | 11 | 10 |
BIGINT, BIN(18,x) | 20 | 19 |
NUM(x, y) or DECIMAL(x, y), where x is an odd number between 1 and 31 | x+1 | x |
NUM(x, y) or DECIMAL(x, y), where x is an even number between 0 and 30 | x+2 | x+1 |
NUM(32,y), DECIMAL(32,y) | 33 | 32 |
n SMALLINT = 1234; u UNICODE(4); // function gets validation error // u must have length of 6 convertNumberToUnicodeNum(n, u); n SMALLINT = 1234; u UNICODE(6); // function sets u to "+001234" convertNumberToUnicodeNum(n, u); n INT = 123456789; u UNICODE(11); // function sets u to // "+0123456789" convertNumberToUnicodeNum(n, u); n BIGINT = -1234567890; u UNICODE(20); // function sets u to // "-0000000001234567890" convertNumberToUnicodeNum(n, u); n BIN(18, 9) = -123456.1234; u UNICODE(20); // function sets u to // "-0000123456123400000" convertNumberToUnicodeNum(n, u); n DECIMAL(31, 4) = 123456789012345678901234567.8901; u UNICODE(32); // function sets u to // "+1234567890123456789012345678901" convertNumberToUnicodeNum(n, u); // Next line gets validation error for COBOL // NUM variables are limited to length 31 for COBOL n NUM(32, 4) = 1234567890123456789012345678.9012; u UNICODE(33); // for Java, function sets u to // "+012345678901234567890123456789012" convertNumberToUnicodeNum(n, u);
Platform | Issue |
---|---|
JavaScript generation | The function convertNumberToUnicodeNum() is not supported. |