Class BytesLenUtils

java.lang.Object
org.legstar.cobol.utils.BytesLenUtils

public class BytesLenUtils extends Object
Cobol byte length for primitive numeric types.
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    static int
    COMP-2 use 8 bytes
    static int
    COMP-1 use 4 bytes
    static int
    packedDecimalByteLen(int totalDigits)
    A packed decimal storage size is the number of bytes needed to store totalDigits + 1 nibbles.
    static int
    zonedDecimalByteLen(int totalDigits, boolean signSeparate)
    Zoned decimals have one byte per digit plus one more byte if the sign is separate.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 digits
      signSeparate - 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