java.lang.Object
org.legstar.cobol.utils.BytesLenUtils
Cobol byte length for primitive numeric types.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intbinaryNumberByteLen(int totalDigits) A COMP binary number bytes occupation depends on the number of decimal digits: 4 or less: 2 bytes 5 to 9: 4 bytes 10 to 18: 8 bytesstatic intCOMP-2 use 8 bytesstatic intCOMP-1 use 4 bytesstatic intpackedDecimalByteLen(int totalDigits) A packed decimal storage size is the number of bytes needed to store totalDigits + 1 nibbles.static intzonedDecimalByteLen(int totalDigits, boolean signSeparate) Zoned decimals have one byte per digit plus one more byte if the sign is separate.
-
Method Details
-
binaryNumberByteLen
public static int binaryNumberByteLen(int totalDigits) A COMP binary number bytes occupation depends on the number of decimal digits:- 4 or less: 2 bytes
- 5 to 9: 4 bytes
- 10 to 18: 8 bytes
- Parameters:
totalDigits- total number of digits- Returns:
- the cobol byte length
-
packedDecimalByteLen
public static int packedDecimalByteLen(int totalDigits) A packed decimal storage size is the number of bytes needed to store totalDigits + 1 nibbles.- Parameters:
totalDigits- total number of digits- Returns:
- the cobol byte length
-
zonedDecimalByteLen
public static int zonedDecimalByteLen(int totalDigits, boolean signSeparate) Zoned decimals have one byte per digit plus one more byte if the sign is separate.- Parameters:
totalDigits- total number of digitssignSeparate- whether the sign occupies an additional byte- Returns:
- the cobol byte length
-
floatByteLen
public static int floatByteLen()COMP-1 use 4 bytes- Returns:
- the cobol byte length
-
doubleByteLen
public static int doubleByteLen()COMP-2 use 8 bytes- Returns:
- the cobol byte length
-