Hi,
What is the difference between zoned and packed decimal in terms of COBOL usage. I don't seetheir usage in langiages like C, C++ etc. so are they just limited to Cobol?
What is the difference between zoned and packed decimal?
- Robert Sample
- Global Moderator
- Posts: 1903
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: What is the difference between zoned and packed decimal?
A z/OS system uses 8-bit bytes. A zoned decimal value allocates the first four bits to a zone (X'C' for positive, X'D' for negative, X'F' for unsigned) and the last four bits to the value. A zoned decimal value will have the positive / negative zone ONLY in the last byte of the value. Hence a zoned decimal value of X'F1F2F3D4' is -1234. A packed decimal value uses the first four bits of each byte to hold a numeric digit, and the last four bits to hold another digit. The sign is indicated by the last four bits of the last byte. So -1234 In packed decimal is X'01234D'.
Their use is typically oriented to the mainframe with its 8-bit bytes. PL/1, Assembler, and COBOL all support zoned decimal and packed decimal variables.
Their use is typically oriented to the mainframe with its 8-bit bytes. PL/1, Assembler, and COBOL all support zoned decimal and packed decimal variables.
Re: What is the difference between zoned and packed decimal?
Thanks Robert. I also get intrigued by the fact that COBOL being one of the early languages then it should have influenced other languages. So, how come there are no direct equivalents of these variables in any other language apart from what you've mentioned and they all are on mainframes. I think there is no one-to-one mapping of some variable from character-set of C, JAVA etc. to the zone or packed decimal of COBOL?
- enrico-sorichetti
- Global Moderator
- Posts: 843
- Joined: Wed Sep 11, 2013 3:57 pm
Re: What is the difference between zoned and packed decimal?
C and JAVA come from a different background(*), where ZONED/PACKED have no meaning
(*) were designed for different hardware architectures
(*) were designed for different hardware architectures
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute