Class NumericFormatBinary

Direct Known Subclasses:
TandemNative

public class NumericFormatBinary extends NumericFormatCompressed
Provides a formatter that emulates COBOL's NumericFormatBinary (COMP) functionality in Java. Given a decimal value and specified total digit count, this class:
1) encodes the value as a two’s-complement binary integer using the minimum byte length
2) decodes the binary representation back into numeric values, preserving sign and magnitude
3) enforces correct byte ordering and length based on digit count
4) handles overflow when the value exceeds the representable range
This implementation delivers an efficient, high-performance Java equivalent of COBOL's binary numeric format for mission-critical data-conversion workflows.
  • Method Details

    • setWordStorage

      public static final void setWordStorage(boolean wordStorage)
    • calculateFormattedCellSize

      public int calculateFormattedCellSize()
    • formatHelper

      protected final String formatHelper(long longVal, boolean isNegative)
      formathelper -
      Parameters:
      longVal -
      Returns:
    • convertFromStorageToDisplayFormat

      public final String convertFromStorageToDisplayFormat(String formattedString)
      Specified by:
      convertFromStorageToDisplayFormat in class Format
    • convertFromCompressedStorageToDisplayFormat

      public final String convertFromCompressedStorageToDisplayFormat(String formattedString)
      Description copied from class: NumericFormatCompressed
      Convert from Storage-Compressed to Display This methods returns the actual stored value, even it is bigger than the defined format.
      E.g. PIC 9(2) COMP can store a value of 30000 ! This method will return "30000", but convertFromStorageToDisplayFormat will return "30".
      Specified by:
      convertFromCompressedStorageToDisplayFormat in class NumericFormatCompressed
      Returns:
    • handleIntegerPart

      protected final void handleIntegerPart(StringBuilder body, boolean[] sizeError)