Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

RULES(NOEVENPACK) in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 109
Location: windsor

PostPosted: Wed Mar 29, 2017 12:47 am    Post subject: RULES(NOEVENPACK) in cobol
Reply with quote

Hello experts,

I am reading the following statment and i am not sure why we must have the pack decimal in odd digit? Is following statement is ture that you can only have odd number of digits in hardware ? Can you give me a example to show why it say that ?? Thank you very much!

Code:
RULES(NOEVENPACK) This complier option will tell you if you accidentally define a Pack Decimal data item within even number of digits. You can only have odd number of digits in hardware. If you have one byte you have one digit , 2 byte you have 3 digit, 3 byte -->5 digit.


Thanks
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Wed Mar 29, 2017 12:54 am    Post subject: Reply to: RULES(NOEVENPACK) in cobol
Reply with quote

Packed decimal variables should have an odd number of digits due to the internal representation. The value 12345 in zoned decimal is X'F1F2F3F4F5' (if unsigned). The same value in packed decimal is X'12345F'. Packed decimal variables that have an odd number of digits will fit precisely into the hexadecimal bytes.

If you have a packed decimal variable with an even number of digits, that extra digit requires an extra byte to store the value. While it is not illegal to have an even number of digits, there are extra pseudo-assembler statements generated in COBOL to account for the extra digit (and make sure the value does not exceed the PICTURE size if TRUNC(STD) is being used). It is more efficient to have the odd number of digits for a packed decimal variable (and note that this ONLY holds true for packed decimal variables).
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 109
Location: windsor

PostPosted: Wed Mar 29, 2017 1:27 am    Post subject:
Reply with quote

Robert, thank you very much for you answer. Could you give me an example of COBOL code to illustrate odd and even pack decimal ? I think i got the idea but still not sure what is the right code should be?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Wed Mar 29, 2017 2:05 am    Post subject:
Reply with quote

I'm not really sure what you think an example is going to show you:
Code:
       05  WS-ODD           PIC S9(07) COMP-3. 
       05  WS-EVEN          PIC S9(08) COMP-3. 
You should always use an odd number of digits, like WS-ODD, and not an even number of digits like WS-EVEN.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Mar 29, 2017 2:23 am    Post subject: Reply to: RULES(NOEVENPACK) in cobol
Reply with quote

jackzhang75,

Please don't post questions in multiple places at the same time. You posted it on StackOverflow, and just wasted either Robert's or my time. That doesn't tend to help you get answers when next you ask.
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 109
Location: windsor

PostPosted: Wed Mar 29, 2017 5:03 am    Post subject:
Reply with quote

Oh.. i am really sorry and i will not post it in anohter place again. Again very appreicated for your answer really help me alot!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us