UNSIGNED( ) function
Returns numeric data converted to the Unsigned data type.
Syntax
UNSIGNED(number, length_of_result)
Parameters
Name | Type | Description |
---|---|---|
number |
numeric |
The value to convert. |
length_of_result | numeric |
The number of bytes to use in the output string. |
Output
Numeric.
Examples
Basic examples
Returns 000075:
UNSIGNED(75, 3)
UNSIGNED(-75, 3)
UNSIGNED(7.5, 3)
Returns 2456 (1 is truncated because only 4 digits can be stored when the length_of_result is 2):
UNSIGNED(12456, 2)
Returns 000000012456:
UNSIGNED(-12.456, 6)
Remarks
What is Unsigned data?
The Unsigned data type is used by mainframe operating systems to store numeric values in a format that uses minimal space, storing two digits in each byte. The Unsigned data type is the same as the Packed data type, but it does not use the last byte to specify whether the value is positive or negative.
When to use UNSIGNED( )
Use the UNSIGNED( ) function to convert numeric data to the Unsigned format for export to mainframe systems.
Truncated return values
If the length_of_result value is shorter than the length of the number value, the additional digits are truncated.