which one is better binary and packed-decimal?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

which one is better binary and packed-decimal?

Postby lxw039 » Wed Oct 22, 2008 6:29 pm

anybody can tell me which one is better define data item as binary and packed-decimal in Cobol, thank you!
lxw039
 
Posts: 47
Joined: Tue Oct 07, 2008 11:49 pm
Has thanked: 0 time
Been thanked: 0 time

Re: which one is better binary and packed-decimal?

Postby dick scherrer » Thu Oct 23, 2008 3:03 am

Hello,

This would depend on how the field(s) were to be used in the code.

Some people believe that binary numbers perform better arithmetically. Usually, it is only slightly better. Some also say binary will save space. Again, usually not so much over packed decimal. 99999 takes 3 bytes both ways. 9999999 takes 4 bytes as comp-3 and 3 bytes as binary. 999999999 takes 5 bytes as comp-3 and 4 as binary.

What many/most people do not realize is the the mainframe has machine instructions that work on packed-decimal numbers. There is also the consideration that to "edit" (commas, currency symbol, sign) the number on a screen or a report, it must be converted from binary to packed-decimal in order to show the value (the assembler EDit instruction requires packed-decimal input, so if the number is not packed-decimal, it is converted internally).

Most of the systems i've supported have standards that require data such as quantities and amounts be stored as comp-3.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: which one is better binary and packed-decimal?

Postby dlmatthews » Thu Oct 23, 2008 6:16 am

Totally agree with the last post, and also when things go wrong COMP-3 fields are usually easier to read in a dump.
dlmatthews
 
Posts: 5
Joined: Thu Oct 23, 2008 5:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: which one is better binary and packed-decimal?

Postby lxw039 » Mon Oct 27, 2008 9:01 pm

thank you very much!
lxw039
 
Posts: 47
Joined: Tue Oct 07, 2008 11:49 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post