This group of values are integer unsigned data type. They can be from 1 to 8 bytes with maximum range from 0 to 18446744073709551615. Unsigned integers don't reserve a bit for a sign and they occupy entire storage with value bits. The summary of unsigned BINARY data type can be found in COBOL Data Types article.
Storage Description
BINARY 1 (1 byte)
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
---|---|---|---|---|---|---|---|
Bit value | Bit value | Bit value | Bit value | Bit value | Bit value | Bit value | Bit value |
BINARY 2 (2 bytes)
Bit 15 | Bit 14 | Bit 13 | ... | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
---|---|---|---|---|---|---|---|
Bit value | Bit value | Bit value | ... | Bit value | Bit value | Bit value | Bit value |
BINARY 4 (4 bytes)
Bit 31 | Bit 30 | Bit 29 | ... | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
---|---|---|---|---|---|---|---|
Bit value | Bit value | Bit value | ... | Bit value | Bit value | Bit value | Bit value |
BINARY 8 (8 bytes)
Bit 63 | Bit 62 | Bit 61 | ... | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
---|---|---|---|---|---|---|---|
Bit value | Bit value | Bit value | ... | Bit value | Bit value | Bit value | Bit value |
Sample 1
255 value
Byte 1 |
---|
1111 1111 |
Explanation
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
---|---|---|---|---|---|---|---|
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
255 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
Sample 2
35,791 value
Byte 2 | Byte 1 |
---|---|
1000 1011 | 1100 1111 |
Explanation
Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit 9 | Bit 8 | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32768 | 0 | 0 | 0 | 2048 | 0 | 512 | 256 | 128 | 64 | 0 | 0 | 8 | 4 | 2 | 1 |
35791 = 32768 + 2048 + 512 + 256 + 128 + 64 + 8 + 4 + 2 + 1
COBOL Representation Samples
01 VAR-BINARY PIC 9(5) USAGE COMP.
01 VAR-BINARY PIC 9(05) USAGE COMP.
01 VAR-BINARY PIC 9(5) COMP.
01 VAR-BINARY PIC 9(5) USAGE COMP.
Resources
- ebcdic-parser tool for converting of mainframe EBCDIC data into Unicode ASCII delimited text
Comments
comments powered by Disqus