Skip to content

Commit 4b43a20

Browse files
committed
adjust formatting
Signed-off-by: MikeBauerCA <[email protected]>
1 parent cfe4902 commit 4b43a20

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,8 +3613,8 @@ A423 is the hexadecimal equivalent of the decimal value 42019:
36133613

36143614
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.
36153615

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
36183618

36193619

36203620
![](Images/hex-binary-conversion.png)
@@ -3635,9 +3635,9 @@ For numerical representations, the last column is of particular interest here; t
36353635

36363636
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.
36373637

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
36413641

36423642

36433643
![](Images/the-9-v-and-s.png)
@@ -3648,11 +3648,11 @@ Since the number of decimal places is determined and fixed in place by the V, th
36483648

36493649
With this background, let us look at the numeric representations in COBOL:
36503650

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
36563656

36573657

36583658
#### Zoned Decimal Format
@@ -3667,9 +3667,9 @@ The zone portion is the ‘upper half byte’ and numeric portion is the ‘lowe
36673667

36683668
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:
36693669

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
36733673

36743674
![](Images/zoned-decimal-values-table.png)
36753675

@@ -3687,11 +3687,11 @@ In the zoned decimal format, the rightmost zone bits determine the sign; the oth
36873687

36883688
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.
36893689

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
36953695

36963696
The COBOL syntax for this format is USAGE IS COMP-3 or just COMP-3.
36973697

@@ -3716,9 +3716,9 @@ The COBOL clauses for this format are COMP, COMP-4, COMPUTATIONAL or BINARY whic
37163716

37173717
The PIC Clause determines the storage space:
37183718

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)
37223722

37233723
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.
37243724

0 commit comments

Comments
 (0)