You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: COBOL Programming Course #1 - Getting Started/COBOL Programming Course #1 - Getting Started.md
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3613,8 +3613,8 @@ A423 is the hexadecimal equivalent of the decimal value 42019:
3613
3613
3614
3614
Although data is encoded in binary on computers, it is rather cumbersome to work with binary. The hexadecimal numerals provide a human friendly representation of the binary coded values. An understanding of this system is invaluable to the COBOL programmer as he designs, develops and tests code. Often, hex dumps of the data in memory are used to debug a program and understand what is going on. The conversion between binary and hexadecimal system is easy as 2<sup>4</sup> = 16. Each hexadecimal digit represents 4 binary digits, also known as a nibble, which is half a byte.
3615
3615
3616
-
-**To convert from hexadecimal to binary, replace each hexadecimal digit with its equivalent 4-bit binary representation**
3617
-
-**To convert from binary to hexadecimal, replace every four consecutive binary digits by their equivalent hexadecimal digits, starting from the rightmost digit and adding zeros, on the left if necessary**
3616
+
- To convert from hexadecimal to binary, replace each hexadecimal digit with its equivalent 4-bit binary representation
3617
+
- To convert from binary to hexadecimal, replace every four consecutive binary digits by their equivalent hexadecimal digits, starting from the rightmost digit and adding zeros, on the left if necessary
3618
3618
3619
3619
3620
3620

@@ -3635,9 +3635,9 @@ For numerical representations, the last column is of particular interest here; t
3635
3635
3636
3636
As a quick reminder, COBOL leverages numeric data with a PIC clause that can contain a 9, V and/or S. These symbols keep the number purely mathematical that can participate in arithmetic.
3637
3637
3638
-
-**9 is used to indicate numeric data consisting of the digits from 0 to 9**
3639
-
-**V indicates where the assumed decimal place is located**
3640
-
-**S will remember the sign which is necessary if the data is negative**
3638
+
- 9 is used to indicate numeric data consisting of the digits from 0 to 9
3639
+
- V indicates where the assumed decimal place is located
3640
+
- S will remember the sign which is necessary if the data is negative
3641
3641
3642
3642
3643
3643

@@ -3648,11 +3648,11 @@ Since the number of decimal places is determined and fixed in place by the V, th
3648
3648
3649
3649
With this background, let us look at the numeric representations in COBOL:
3650
3650
3651
-
-**Zoned Decimal (Fixed Point)**
3652
-
-**Packed Decimal (Fixed Point)**
3653
-
-**Binary (Fixed Point)**
3654
-
-**Single Precision Floating Point**
3655
-
-**Double Precision Floating Point**
3651
+
- Zoned Decimal (Fixed Point)
3652
+
- Packed Decimal (Fixed Point)
3653
+
- Binary (Fixed Point)
3654
+
- Single Precision Floating Point
3655
+
- Double Precision Floating Point
3656
3656
3657
3657
3658
3658
#### Zoned Decimal Format
@@ -3667,9 +3667,9 @@ The zone portion is the ‘upper half byte’ and numeric portion is the ‘lowe
3667
3667
3668
3668
As discussed earlier, the first two declarations above are unsigned, indicated by the absence of a S. Such numbers are ‘implied positive’. The next two declarations are explicitly signed by the symbol S and are capable of representing positive and negative numbers. The sign is represented by the rightmost zone bits (in the above example the F above the 5) and is determined as follows:
3669
3669
3670
-
-**F indicates the number is unsigned**
3671
-
-**C indicates the number is positive**
3672
-
-**D indicates the number is negative**
3670
+
- F indicates the number is unsigned
3671
+
- C indicates the number is positive
3672
+
- D indicates the number is negative
3673
3673
3674
3674

3675
3675
@@ -3687,11 +3687,11 @@ In the zoned decimal format, the rightmost zone bits determine the sign; the oth
3687
3687
3688
3688
As we can observe, when the number is packed into a field that is larger than necessary to hold that number, it is padded with zeroes on the left.
3689
3689
3690
-
-**Number 1 will be stored as X’1F’ in 1 byte**
3691
-
-**Number +12 will be stored as X’012C’ in 2 bytes**
3692
-
-**Number -123 will be stored as X’123D’ in 2 bytes**
3693
-
-**Number 1234 (unsigned) will be stored as X’01234F’ in 3 bytes**
3694
-
-**Number +12345 will be stored as X’12345C’ in 3 bytes**
3690
+
- Number 1 will be stored as X’1F’ in 1 byte
3691
+
- Number +12 will be stored as X’012C’ in 2 bytes
3692
+
- Number -123 will be stored as X’123D’ in 2 bytes
3693
+
- Number 1234 (unsigned) will be stored as X’01234F’ in 3 bytes
3694
+
- Number +12345 will be stored as X’12345C’ in 3 bytes
3695
3695
3696
3696
The COBOL syntax for this format is USAGE IS COMP-3 or just COMP-3.
3697
3697
@@ -3716,9 +3716,9 @@ The COBOL clauses for this format are COMP, COMP-4, COMPUTATIONAL or BINARY whic
3716
3716
3717
3717
The PIC Clause determines the storage space:
3718
3718
3719
-
-**PIC 9(1) through PIC 9(4) will reserve 2 bytes (Binary halfword)**
3720
-
-**PIC 9(5) through PIC 9(9) will reserve 4 bytes (Binary fullword)**
3721
-
-**PIC 9(10) through PIC 9(18) will reserve 8 bytes (Binary doubleword)**
3719
+
- PIC 9(1) through PIC 9(4) will reserve 2 bytes (Binary halfword)
3720
+
- PIC 9(5) through PIC 9(9) will reserve 4 bytes (Binary fullword)
3721
+
- PIC 9(10) through PIC 9(18) will reserve 8 bytes (Binary doubleword)
3722
3722
3723
3723
Next, let’s look at what numbers can be stored. For the COMP and COMP-4 fields, although the data is stored as binary numbers, the range is limited by the full value of the PIC Clause used in the field definition. The binary format, COMP-5 (also known as ‘Native Binary’) in which the PIC clause still defines the size of the field but the range of values that can be represented is much higher as every possible bit-value combination is valid.
0 commit comments