Zoned Decimal Format
Description and Discussion
  Table of Contents  v-24.01.01 - datazd01.htm 
  Introduction
  Physical Structure for Zone-Decimal
  Zone-Decimal, Strict Definition
  Zone-Decimal, Modified Definition
  Sign for Zone-Decimal, Strict Definition
  Sign for Zone-Decimal, Modified
  Additional Items to Consider
  Leading Spaces Treated as Zeroes
  Program Logic, "{}" or "A-R" Compare
  CHARSET(ASCII) and SIGN(EBCDIC)
  Summary
  Software Agreement and Disclaimer
  Downloads & Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Contact or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This document will focus on a discussion of a numeric field (or data string) format referred to as zoned decimal and is commonly used on an IBM Mainframe System. This is the default numeric format for COBOL and may be explicitly defined with the "USAGE IS DISPLAY" clause.

Note: The items in this document are appropriate for applications that are written in COBOL, Mainframe Assembler (HLASM) or PL/I. The IBM Mainframe architecture drove many of the numeric formats that existed in the early ANSI specifications for COBOL and have been carried forward to the current COBOL ANSI specifications.

The "SIGNED, ZONED-DECIMAL" format has caused problems for years for mainframe programmers because the signed position of the field will display as a character value of "A-I" for positive numbers and "J-R" for negative numbers. It also allows for a positive and negative zero value that will display as a "{" and "}", this is the curly brace symbol or x'C0' and x'D0'.

When converting this type of field from EBCDIC to ASCII the programmer is presented with a number of confusing options and challenges. This document will try to explain the options and help the programmer avoid the common mistakes that are made during a conversion process.


We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.

Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Physical Structure for Zone-Decimal

Numeric fields that are zoned-decimal format (unsigned or signed, positive or negative) require additional consideration when displaying, printing or converting between EBCDIC and ASCII. Lets quickly answer the question, "Why is the term zoned-decimal used to describe this numeric format?"

The terms "Zone" and "Decimal" have been carried forward from when computers used punched cards for input and output. The punched card had eighty vertical columns and twelve horizontal rows. The columns were simply numbered 1-80. The top two rows were numbered "12" and "11". The remaining rows were referred to as rows 0 through 9. The top three rows were referred to as the Zones (the 12, 11 and 0 rows). Rows 1 through 9 were referred to as the Decimal rows (with the 0 (zero) row doing double duty as the decimal 0). When a column contained a single hole (a punch) in a decimal row it was equivalent to a positive digit or number. To create a negative value required a second punch in the column that represented the units position of a numeric field (or data string). For negative numbers this was the eleven row. This solved the problem of storing positive and negative numbers in the limited space available on a punched card but was the beginning of an annoying little problem that still exist today. This little problem can be understood when we take a look at how the alphabet was stored on a punched card. The upper-case, alphabetic characters required two punches in each column that contained a letter. For the letters A-I the twelve-punch was used along with a 1-9 punch. For the letters J-R the eleven-punch was used along with a 1-9 punch. For the letters S-Z the zero-punch was used along with a 2-9 punch. Here is the problem, the punched hole pattern for the letters "J" through "R" are the same as the punched hole pattern for the signed, negative numbers of 1 through 9.

The following table shows the structure of a five digit numeric field using the Zoned-Decimal format (i.e. the COBOL syntax would be USAGE IS DISPLAY). The field contains a value of one-hundred-twenty-three (or 00123).

The Zoned Decimal Format for a Numeric Field
Byte-0 Byte-1 Byte-2 Byte-3 Byte-4  Description
0 0 1 2 3  Numeric Value
Zone   Digit
1111   0000
 0
   
   
   
   
0011   0000
 0
   
   
   
   
Zone   Digit
1111   0000
 0
   
   
   
   
0011   0000
 0
   
   
   
   
Zone   Digit
1111   0001
 1
   
   
   
   
0011   0001
 1
   
   
   
   
Zone   Digit
1111   0010
 2
   
   
   
   
0011   0010
 2
   
   
   
   
Zone   Digit
1111   0011
 3
1100   0011
 3
1101   0011
 3
0011   0011
 3
0011   0011
 3
0111   0011
 3
 Left & Right Nibble
 EBCDIC (Unsigned, Binary, Note-1)
 EBCDIC (Unsigned, Hex, Note-2)
 EBCDIC (Sign, Positive, Binary)
 EBCDIC (Sign, Positive, Hex)
 EBCDIC (Sign, Negative, Binary)
 EBCDIC (Sign, Negative, Hex)
 ASCII (Unsigned, Binary)
 ASCII (Unsigned, Hex)
 ASCII (Sign, Positive, Binary)
 ASCII (Sign, Positive, Hex)
 ASCII (Sign, Negative, Binary)
 ASCII (Sign, Negative, Hex)

Note-1: A field that is defined as "Unsigned" (i.e. PIC 99999) is an implied positive value.
Note-2: The "Hex" is an abbreviation for Hexadecimal notation.
Note-3: A field that is defined as "Signed" (i.e. PIC S99999) will have the sign in the "Zone" nibble of the units positions (or Byte-4 in the preceding example, Byte-0 through Byte-3 will be the same for Unsigned and Signed fields). For the EBCDIC-encoded environment a X'Cn' is used as an explicit positive sign and a X'Dn' is used as an explicit negative sign. For the ASCII-encoded environment a X'3n' is used as an explicit positive sign and a X'7n' is used as an explicit negative sign.

The two options for maintaining the numeric format as zoned-decimal are covered in the following sections.

Table of Contents Previous Section Next Section Zone-Decimal, Strict Definition

This section discusses how to maintain zoned-decimal fields or data strings in ASCII or EBCDIC and abide by the strict definition of the zoned-decimal format. The terms "signed" or "unsigned" are used when referring to numeric fields and this includes numeric, zoned-decimal fields. I prefer the terms "explicitly signed" or "implied positive". We also need to be aware that it is possible to have a "signed" field that contains zero and we could have a plus or minus zero value.

For unsigned (or implied positive) fields each digit is represented by a zoned bit value in the left-most four bits (nibble or half-word) and the binary value for the digit in the right-most four bits (nibble or half-word).
This would be x'F0' through x'F9' or b'11110000' through b'11111001' for EBCDIC encoding.
This would be x'30' through x'39' or b'00110000' through b'00111001' for ASCII encoding.

Note: For unsigned, zoned-decimal fields negative numbers are not allowed, all numbers are considered positive.

For signed fields the sign position (usually the low-order byte or units position) will have the ZONE, high-order four bits (left-most nibble or half-word) represent the sign and the DECIMAL, low order four bits (right-most nibble or half-word) is the binary value for the digit.

The EBCDIC format for signed, positive numbers in all positions except the sign position will be x'Fn' or b'1111nnnn . The sign position will be x'Cn' or b'1100nnnn'. The ASCII format for signed, positive numbers in all positions including the sign position will be x'3n' or b'0011nnnn'.

The EBCDIC format for signed, negative numbers in all positions except the sign position will be x'Fn' or b'1111nnnn . The sign position will be x'Dn' or b'1101nnnn'. The ASCII format for signed, negative numbers in all positions except the sign position will be x'3n' or b'0011nnnn'. The sign position will be x'7n' or b'0111nnnn'.

Note: For the EBCDIC environment the unsigned and signed, positive values are arithmetically equal but physically different because of the low-order byte or units position (or the sign position).
For the ASCII environment the unsigned and signed, positive values are arithmetically and physically equal.

Table of Contents Previous Section Next Section Zone-Decimal, Modified Definition

A modified-zoned-decimal format occurs when the sign position (trailing or leading) is translated based on the character display value. The sign position (trailing or leading) will have the high-order four bits (left-most nibble or half-word) represent the sign and low order four bits (right-most nibble or half-word) represent the digit.

The EBCDIC format for positive numbers (i.e. unsigned or implied positive) in all positions except the sign position will be x'Fn' or b'1111nnnn. For the sign position will be 'Cn' or b'1100nnnn'.

The ASCII format for positive numbers in all positions including the sign position will be x'3n' or b'0011nnnn' and the 'n' or 'nnnn' is the binary representation of the digit. The ASCII encoding format does not have two different representations for positive, zoned-decimal numbers.

When zoned-decimal fields are converted based on their character value (not their numeric value) the sign position will no longer abide by the definition of zoned-decimal. The signed, positive digits of 1-9 in EBCDIC are represented by x'C1' through x'C9' which is also the representation for the letters "A" through "I". When these are converted to the ASCII letters "A" through "I" or x'41' through x'49' the result is not in accordance with the ASCII definition for a positive value. This would maintain the rightmost nibble as a binary digit value and this is in accordance with the definition of zoned-decimal.

The next departure from the definition of zoned-decimal happens with the positive zero and negative zero through nine. A zero with a positive or negative sign in EBCDIC is x'C0' and x'D0' which is also the representation for special characters "{" and "}". Using the modified-zoned-decimal these translate to the ASCII values for "{" and "}" which is x'7B' and x'7D' and the rightmost nibble is no longer the binary value of the digit. The same is true for the negative digits 1 through 9. The EBCDIC is x'D1' through x'D9' which are the same as the letters "J" through "R". These are translated to the ASCII values of "J" through "R" which are x'4A' through x''52'. The leftmost nibble is inconsistent for a sign value and the rightmost nibble is no longer the binary value of the digit. This is a departure from the definition of zoned-decimal.

Micro Focus supports both the zoned-decimal and the modified-zoned-decimal. Refer to the SIGN(EBCDIC) directive for supporting the modified-zoned-decimal format. The directive SIGN(EBCDIC) should only be used in an EBCDIC encoded environment. For the ASCII encoded environment it should only be used with caution for exception processing.

Note: when using FTP in ASCII mode to transfer a file that contains zoned-decimal fields (or data strings) the sign position of the field will be translated based on its character value not its numeric value. This is performing a non-arithmetic function on a numeric field and results in a non-numeric format or modified-zoned-decimal format.

Table of Contents Previous Section Next Section Sign for Zone-Decimal, Strict Definition

The following is a table of values for the sign position of a Zone-Decimal (strict definition) field using EBCDIC or ASCII encoding.

Digit EBCDIC
Hex-Binary
EBCDIC Display ASCII
Hex-Binary
ASCII Display
+0 X'C0' - 1100 0000 { X'30' - 0011 0000 0
+1 X'C1' - 1100 0001 A X'31' - 0011 0001 1
+2 X'C2' - 1100 0010 B X'32' - 0011 0010 2
+3 X'C3' - 1100 0011 C X'33' - 0011 0011 3
+4 X'C4' - 1100 0100 D X'34' - 0011 0100 4
+5 X'C5' - 1100 0101 E X'35' - 0011 0101 5
+6 X'C6' - 1100 0110 F X'36' - 0011 0110 6
+7 X'C7' - 1100 0111 G X'37' - 0011 0111 7
+8 X'C8' - 1100 1000 H X'38' - 0011 1000 8
+9 X'C9' - 1100 1001 I X'39' - 0011 1001 9
-0 X'D0' - 1101 0000 } X'70' - 0111 0000 p
-1 X'D1' - 1101 0001 J X'71' - 0111 0001 q
-2 X'D2' - 1101 0010 K X'72' - 0111 0010 r
-3 X'D3' - 1101 0011 L X'73' - 0111 0011 s
-4 X'D4' - 1101 0100 M X'74' - 0111 0100 t
-5 X'D5' - 1101 0101 N X'75' - 0111 0101 u
-6 X'D6' - 1101 0110 O X'76' - 0111 0110 v
-7 X'D7' - 1101 0111 P X'77' - 0111 0111 w
-8 X'D8' - 1101 0100 Q X'78' - 0111 1000 x
-9 X'D9' - 1101 1001 R X'79' - 0111 1001 y

Table of Contents Previous Section Next Section Sign for Zone-Decimal, Modified

The following is a table of values for the sign position of a Modified-Zone-Decimal field using EBCDIC or ASCII encoding.

Digit EBCDIC
Hex-Binary
EBCDIC Display ASCII
Hex-Binary
ASCII Display
+0 X'C0' - 1100 0000 { X'7B' - 0111 1011 {
+1 X'C1' - 1100 0001 A X'41' - 0100 0001 A
+2 X'C2' - 1100 0010 B X'42' - 0100 0010 B
+3 X'C3' - 1100 0011 C X'43' - 0100 0011 C
+4 X'C4' - 1100 0100 D X'44' - 0100 0100 D
+5 X'C5' - 1100 0101 E X'45' - 0100 0101 E
+6 X'C6' - 1100 0110 F X'46' - 0100 0110 F
+7 X'C7' - 1100 0111 G X'47' - 0100 0111 G
+8 X'C8' - 1100 1000 H X'48' - 0100 1000 H
+9 X'C9' - 1100 1001 I X'49' - 0100 1001 I
-0 X'D0' - 1101 0000 } X'7D' - 0111 1101 }
-1 X'D1' - 1101 0001 J X'4A' - 0100 1010 J
-2 X'D2' - 1101 0010 K X'4B' - 0100 1011 K
-3 X'D3' - 1101 0011 L X'4C' - 0100 1100 L
-4 X'D4' - 1101 0100 M X'4D' - 0100 1101 M
-5 X'D5' - 1101 0101 N X'4E' - 0100 1110 N
-6 X'D6' - 1101 0110 O X'4F' - 0100 1111 O
-7 X'D7' - 1101 0111 P X'50' - 0101 0000 P
-8 X'D8' - 1101 0100 Q X'51' - 0101 0001 Q
-9 X'D9' - 1101 1001 R X'52' - 0101 0010 R

Table of Contents Previous Section Next Section Additional Items to Consider

This section describes possible situations that need special consideration and may take extra time to properly address.

Table of Contents Previous Section Next Section Leading Spaces Treated as Zeroes

On the mainframe leading spaces are allowed in a zoned-decimal, numeric field. In the Micro Focus environment the HOSTARITHMETIC and HOSTCOMPARE directives must be used. If these directives are not used and a field with leading spaces is encountered then a 163 message (non-numeric character in a numeric field) will cause the program to ABEND (ABnormal END).

Table of Contents Previous Section Next Section Program Logic, "{}" or "A-R" Compare

When using the strict definition of zoned-decimal in an ASCII encoded environment the comparing of the sign position for the characters of "{" and "}" will fail (on the mainframe and in the EBCDIC environment the values for a zero in the sign position of a signed-zoned-decimal field just happens to be the same as the left or right curly brace). The sign position for a positive and negative zero will be "0" (for ASCII a positive number will be printable) and "p" (this is lower case). For the EBCDIC environment the sign position for a "negative 1" through a "negative 9" are the values "J" through "R" (upper case). For ASCII this will be changed to "q" through "y" (lower case).

Table of Contents Previous Section Next Section CHARSET(ASCII) and SIGN(EBCDIC)

The Micro Focus environment may be configured to run in CHARSET(EBCDIC) or CHARSET(ASCII) mode. In the CHARSET(EBCDIC) environment the directive for the sign is automatically set to SIGN(EBCDIC). In the CHARSET(ASCII) environment the directive for the sign is automatically set to SIGN(ASCII). Programmers should avoid using a different encoding scheme for the CHARSET and the SIGN because this will cause problems with the signed, zoned-decimal numeric fields. For example, using SIGN(EBCDIC) with a CHARSET(ASCII) environment will cause numeric check failures and 163 error messages that will cause the program execution to ABEND (ABnormally END).

If a data file conversion from EBCDIC to ASCII is done using the Data File Converter (DFCONV) with Micro Focus Mainframe Express (MFE is an EBCDIC environment) then you will have a problem if the file has records with numbers that are signed, zone-decimal because the SIGN(EBCDIC) will be used. Therefore, the data file conversion should be done using Net Express with the .STR and .PRO files being created in a project that is CHARSET(ASCII).

Now comes the CATCH-22, if a file has multiple record types and the record layout is determined by a specific character in a specific position in the record then the .STR and .PRO file must be created in a CHARSET(EBCDIC) project. This is required in order for the conditional arguments to be created as EBCDIC-encoded values in order to properly compare with the EBCDIC-encoded values in the file being converted. In this situation it may be necessary to use the SimoTime conversion technology instead of the Micro Focus Data File Converter (DFCONV).

Table of Contents Previous Section Next Section Summary

The purpose of this document is to provide an overview of numeric data strings or fields that are zoned-decimal format. This document may be used as a tutorial for new programmers or as a quick reference for experienced programmers.

In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.

SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the  Contact or Feedback  section of this document.

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Technologies.

SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Technologies shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material.

Table of Contents Previous Section Next Section Downloads & Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first sub-section requires an internet connection, the second sub-section references locally available documents.

Note: A SimoTime License is required for the items to be made available on a local server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the Link to Internet icon. If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the Link to Server icon.

Link to Internet   Link to Server   Explore The Binary or COMP format for numeric data strings. This numeric structure is supported by COBOL and may be explicitly defined with the "USAGE IS COMP" or "USAGE IS BINARY" clause.

Link to Internet   Link to Server   Explore The Edited for Display format for numeric data strings. This numeric structure is supported by COBOL and may be used with an edit-mask to prepare the presentation for readability by human beings.

Link to Internet   Link to Server   Explore The Packed-Decimal or COMP-3 format for numeric data strings. This numeric structure is supported by COBOL and may be explicitly defined with the "USAGE IS COMP-3" clause.

Link to Internet   Link to Server   Explore The Zoned-Decimal format for numeric data strings. This numeric structure is the default numeric for COBOL and may be explicitly defined with the "USAGE IS DISPLAY" clause.

Link to Internet   Link to Server   Explore commonly used formats and processing techniques for managing various numeric formats available on the mainframe.

Link to Internet   Link to Server   Explore the Numbers Connection for additional information about the structure and processing of numeric data items (or numeric fields).

Link to Internet   Link to Server   Explore how to process Numeric and non-Numeric Values stored in a Zoned-Decimal format. This document will use examples to show how to manage a situation where non-numeric values (such as high-values or X'FF') are intentionally placed in a Zoned-Decimal field and then properly managed to obtain the desired business result.

Link to Internet   Link to Server   Explore how to process non-Numeric Values stored in a Zoned-Decimal format. This document will use examples to show how to manage a situation where non-numeric values are placed in a Zoned-Decimal field. The fields are then processed using techniques that will avoid a S0C7 or RTS 163 error message and an abnormal termination of the program.

Link to Internet   Link to Server   Explore how to Calculate a Record Count and Accumulate Summary Totals by reading a Record Sequential Data File. Each record contains numeric fields with a Zoned-Decimal (USAGE IS DISPLAY) format. The count and totals will be posted to the SYSOUT device.

Link to Internet   Link to Server   Explore How to Generate a Data File Convert Program using simple specification statements in a Process Control File (PCF). This link to the User Guide includes the information necessary to create a Process Control File and generate the COBOL programs that will do the actual data file conversion. The User Guide contains a list of the PCF statements that are used for the data file convert process.

Link to Internet   Link to Server   Explore a typical data file conversion process that may be required when working in a multi-system environment. This suite of documents describes a model for managing non-relational data structures (Sequential Files and VSAM Data Sets) that contain ASCII or EBCDIC text strings and various numeric formats such as BINARY, PACKED-Decimal and ZONED-Decimal. This model has the capability of creating a test file for an ASCII or EBCDIC encoded environment. This suite of documents will address many of the challenges of doing a record content conversion of a file that will be transferred between an EBCDIC-encoded Mainframe System and an ASCII-encoded Linux, UNIX or Windows System.

Link to Internet   Link to Server   Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.

Link to Internet   Link to Server   Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection

Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.

Explore the GnuCOBOL Technologies available from SourceForge. SourceForge is an Open Source community resource dedicated to helping open source projects be as successful as possible. GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler with run time support. The compiler (cobc) translates COBOL source to executable using intermediate C, designated C compiler and linker. This link will require an Internet Connection.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Contact or Feedback

This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.

1. Send an e-mail to our helpdesk.
1.1. helpdesk@simotime.com.
2. Our telephone numbers are as follows.
2.1. 1 415 763-9430 office-helpdesk
2.2. 1 415 827-7045 mobile

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.

Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Zoned Decimal Format, Description and Discussion
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com