Skip to content

Commit a3f13d4

Browse files
authored
Merge pull request #178 from raven300/Update-COBOL-Numerical-Values
Signed-off-by: MikeBauerCA <[email protected]>
2 parents 44966a5 + bc3df24 commit a3f13d4

31 files changed

+213
-15
lines changed

COBOL Programming Course #1 - Getting Started/COBOL Programming Course #1 - Getting Started.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,17 +3557,14 @@ This lab requires two COBOL programs, CBL0008 and CBL0009 and two respective JCL
35573557
\newpage
35583558

35593559
# Data types
3560-
35613560

35623561
A COBOL programmer must be aware that the computer stored internal data representation and formatting can differ, where the difference must be defined in the COBOL source code. Understanding the computer's internal data representation requires familiarity with binary, hexadecimal, ASCII, and EBCDIC. Packed-Decimal is needed to explain COBOL Computational and Display data format. This chapter aims to familiarize the reader with these different "types" of data representation.
35633562

3564-
3565-
35663563
- **Data representation**
35673564

35683565
- **Numerical value representation**
35693566

3570-
- **Text representations**
3567+
- **Text representation**
35713568

35723569
- **COBOL DISPLAY vs COMPUTATIONAL**
35733570

@@ -3578,10 +3575,9 @@ A COBOL programmer must be aware that the computer stored internal data represen
35783575

35793576
Data such as numerical values and text are internally represented by zeros and ones in most computers, including mainframe computers used by enterprises. While data representation is a somewhat complex topic in computer science, a programmer does not always need to fully understand how various alternative representations work. It is important, however, to understand the differences and how to specify a specific representation when needed.
35803577

3581-
35823578
### Numerical value representation
35833579

3584-
COBOL has five computational (numerical) value representations. The awareness of these representations is important due to two main reasons. The first reason being, when a COBOL program needs to read or write data, it needs to understand how data is represented in the dataset. The second reason is when there are specific requirements regarding the precision and range of values being processed. The following sections describe each computational representation keyword.
3580+
COBOL has five computational (numerical) value representations. The awareness of these representations is important due to two main reasons. The first reason being, when a COBOL program needs to read or write data, it needs to understand how data is represented in the dataset. The second reason is when there are specific requirements regarding the precision and range of values being processed. For additional details on binary and hexadecimal numbering systems as well as these numeric representations, consider reading the "Numerical Data Representation" chapter in the advanced topics course.
35853581

35863582
#### COMP-1
35873583

@@ -3591,16 +3587,12 @@ This is also known as a single-precision floating point number representation.
35913587

35923588
This is also known as a double-precision floating point number representation. COMP-2 extends the range of value that can be represented compared to COMP-1. COMP-2 can represent values up to about 10 to the power of 307. Like COMP-1, COMP-2 values also have a limited precision. Due to the expanded format, COMP-2 has more significant digits, approximately 15 decimal digits. This means that once a value reaches certain quadrillions (with no decimal places), it can no longer be exactly represented in COMP-2.
35933589

3594-
3595-
35963590
COMP-2 supersedes COMP-1 for more precise scientific data storage as well as computation. Note that COMP-1 and COMP-2 have limited applications in financial data representation or computation.
35973591

35983592
#### COMP-3
35993593

36003594
This is also known as packed BCD (binary coded decimal) representation. This is, by far, the most utilized numerical value representation in COBOL programs. Packed BCD is also somewhat unique and native to mainframe computers such as the IBM z architecture.
36013595

3602-
3603-
36043596
Unlike COMP-1 or COMP-2, packed BCD has no inherent precision limitation that is independent to the range of values. This is because COMP-3 is a variable width format that depends on the actual value format. COMP-3 exactly represents values with decimal places. A COMP-3 value can have up to 31 decimal digits.
36053597

36063598
#### COMP-4
@@ -3609,11 +3601,10 @@ COMP-4 is only capable of representing integers. Compared to COMP-1 and COMP-2,
36093601

36103602
#### COMP-5
36113603

3612-
COMP-5 is based on COMP-4, but with the flexibility of specifying the position of a decimal point. COMP-5 has the space efficiency of COMP-4, and the exactness of COMP-3. Unlike COMP-3, however, a COMP-5 value cannot exceed 18 decimal digits.
3604+
COMP-5 is based on COMP-4, but with the flexibility of specifying the position of a decimal point. COMP-5 has the space efficiency of COMP-4, and the exactness of COMP-3. Unlike COMP-3, however, a COMP-5 value cannot exceed 18 decimal digits..
36133605

3614-
36153606

3616-
### Text representations
3607+
### Text representation
36173608

36183609
COBOL programs often need to represent text data such as names and addresses.
36193610

@@ -3638,7 +3629,7 @@ COBOL can encode and process text data in EBCDIC or ASCII. This means a COBOL p
36383629

36393630
## COBOL DISPLAY vs COMPUTATIONAL
36403631

3641-
Enterprise COBOL for z/OS by default utilizes EBCDIC encoding. However, it is possible to read and write ASCII in z/OS. The EBCDIC format representation of numbers and alphabetic characters is in a DISPLAY format. Packed decimal and zoned decimal are NOT in a DISPLAY format. COBOL can describe packed decimal and zoned decimal fields using COMPUTATIONAL, COMP-1, COMP-2, COMP-3, COMP-4, and COMP-5 reserved words.
3632+
Enterprise COBOL for z/OS by default utilizes EBCDIC encoding. However, it is possible to read and write ASCII in z/OS. The EBCDIC format representation of alphabetic characters is in a DISPLAY format. Zoned decimal for numbers, without the sign, is in a DISPLAY format. Packed decimal, binary and floating point are NOT in a DISPLAY format. COBOL can describe packed decimal, binary and floating point fields using COMPUTATIONAL, COMP-1, COMP-2, COMP-3, COMP-4, and COMP-5 reserved words.
36423633

36433634

36443635
## Lab

0 commit comments

Comments
 (0)