Page 1 of 1

which one is better binary and packed-decimal?

PostPosted: Wed Oct 22, 2008 6:29 pm
by lxw039
anybody can tell me which one is better define data item as binary and packed-decimal in Cobol, thank you!

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

PostPosted: Thu Oct 23, 2008 3:03 am
by dick scherrer
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.

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

PostPosted: Thu Oct 23, 2008 6:16 am
by dlmatthews
Totally agree with the last post, and also when things go wrong COMP-3 fields are usually easier to read in a dump.

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

PostPosted: Mon Oct 27, 2008 9:01 pm
by lxw039
thank you very much!