Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bytes used for various numeric fields?

Status
Not open for further replies.

qotyebw

Programmer
Aug 24, 2000
103
0
0
US
I'm reviewing MVS COBOL basics in preparation for my next job. Yet in all of my texts, there's no attention paid to byte-size for various types of numeric fields. I'll bet that a tech evaluationt will dwell on this subject.
I know there's a chapter, or web tutorial somehwere that deals with this.

Is there a good prep of some kind that will allow me to do better on one of those tech-tests?
 
Hi,

If you search for info on this subject the term is "COBOL data representation". I doubt you'll find anything using "byte size".

Hope this helps.
 
Here are the formulas used for the two most popular non-character data representations on the machine in question, packed-decimal a.k.a. comp-3 and binary a.k.a. comp:

Packed decimal:
#Bytes = (Total digits + 1)/2 If this results in any half-bytes, round up.

Binary:

Total digits #Bytes
1-4 2 (One halfword)
5-9 4 (One fullword)
10-18 8 (One doubleword)

Other data formats are used, but infrequently. These two are the most common. These can be found in a COBOL manual usually listed under the USAGE clause. Number of different USAGEs varies by machine, but as I said, these are the primary ones used for MVS. Betty Scherber
Brainbench MVP for COBOL II
 
There are several formats for packing numeric fields in Cobol. Comp, comp-1, comp-2, comp-3, comp-4, comp-5, comp-x and probably more.
Each require their own table for the number of bytes used to store a specified number of digits (signed or unsigned).
My MicroFocus NetExpress Language Reference Manual has the tables for all of the above formats. These tables are also in the CTOS Cobol language reference manuals. Whatever Cobol you are currently working on should have these tables somewhere in their manuals.
 
Thanks, guys. I really did not pose the question correctly. Yes, it was the COMP- fields break-down that I was wanting to review. It's all coming back to me now.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top