This group of values are integer signed data type. They can be from 1 to 8 bytes with maximum range from -9223372036854775808 to 9223372036854775807. Signed integers are represented 0 in the leftmost bit for positive values and 1 for negative ones. The summary of signed 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 |
---|---|---|---|---|---|---|---|
Sign | 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 |
---|---|---|---|---|---|---|---|
Sign | 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 |
---|---|---|---|---|---|---|---|
Sign | 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 |
---|---|---|---|---|---|---|---|
Sign | Bit value | Bit value | ... | Bit value | Bit value | Bit value | Bit value |
Sample 1
35,791 value
Byte 4 | Byte 3 | Byte 2 | Byte 1 |
---|---|---|---|
0000 0000 | 0000 0000 | 1000 1011 | 1100 1111 |
Explanation
Bit 31 | ... | Bit 16 | 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | ... | 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
Sample 2
-35,791 value
Byte 4 | Byte 3 | Byte 2 | Byte 1 |
---|---|---|---|
1111 1111 | 1111 1111 | 0111 0100 | 0011 0001 |
Explanation
Bit 31 | ... | 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2147483648 | ... | 0 | 16384 | 8192 | 4096 | 0 | 1024 | 0 | 0 | 0 | 0 | 32 | 16 | 0 | 0 | 0 | 1 |
-35791 = -([maximum of unsigned 4 byte integer: 4294967295] - [2147483648...16384+8192+4096+1024+32+16+1] + 1)
COBOL Representation Samples
01 VAR-BINARY PIC S9(5) USAGE COMP.
01 VAR-BINARY PIC S9(05) USAGE COMP.
01 VAR-BINARY PIC S9(5) COMP.
01 VAR-BINARY PIC S9(5) USAGE COMP.
Resources
- ebcdic-parser tool for converting of mainframe EBCDIC data into Unicode ASCII delimited text
Comments
comments powered by Disqus