ZONE
Use ZONE to convert a number to a zoned (signed) number.
The ZONE function converts a signed integer item to a text item that can be interpreted as a number with a superimposed sign in the rightmost byte (called zoned or signed).
You can define items as having a zoned character number presentation. Then, when mapping to or from these items, the conversion to and from zoned decimal is performed automatically, as needed.
- Syntax:
- ZONE ( single-integer-expression , single-integer-expression )
- Meaning:
- ZONE ( integer_to_convert , sign_indicator )
- Returns:
- A single text item
ZONE returns a text string that represents a zoned (signed) number representing integer_to_convert.
Zoned integers have a sequence of digits except for the rightmost byte. The rightmost byte is a digit with a super-imposed sign. The sign_indicator specifies whether a super-imposed sign is required for positive integers, where 0 specifies no sign is required and any other value specifies that a sign is required for positive integers.
The following tables show positive and negative values of the numbers 1230 to 1239, with a sign indicator of 0 (no sign is required for positive values) or a sign of 1 (include a sign for both positive and negative values) in the rightmost byte.
Integer Value | sign_indicator = 0 | sign_indicator = 1 |
---|---|---|
1230 | 1230 | 123{ |
1231 | 1231 | 123A |
1232 | 1232 | 123B |
1233 | 1233 | 123C |
1234 | 1234 | 123D |
1235 | 1235 | 123E |
1236 | 1236 | 123F |
1237 | 1237 | 123G |
1238 | 1238 | 123H |
1239 | 1239 | 123I |
Integer Value | sign_indicator = 0 | sign_indicator = 1 |
---|---|---|
-1230 | 123} | 123} |
-1231 | 123J | 123J |
-1232 | 123K | 123K |
-1233 | 123L | 123L |
-1234 | 123M | 123M |
-1235 | 123N | 123N |
-1236 | 123O | 123O |
-1237 | 123P | 123P |
-1238 | 123Q | 123Q |
-1239 | 123R | 123R |
Examples
- ZONE ( 1234 , 0 )
Returns 1234
- ZONE ( 1234 , 1 )
Returns 123D
- ZONE ( -1234 , 1 )
Returns 123M
- ZONE ( INT ( UnitPrice * 100 ) , 1 )
UnitPrice is multiplied by 100 to move the first two decimal places to the left of the decimal sign. The result of this calculation is converted to an integer using the INT function. Finally, the result of the INT is converted to zoned format, using a sign for positive values.
Related function
- UNZONE