All the converter routines require the precision of the decimal value to convert, which represents the number of decimal digits in the decimal value, not including the sign.
Unicode Decimal values can be represented as either a char array or as a byte array where every Unicode character is represented by a pair of adjacent bytes.
For embedded sign nibbles (4 bit integers representing values between 0x0
and 0xF
inclusive) in External Decimal or Packed Decimal data, 0xB
and 0xD
represent a negative
sign. All other sign nibble values represent a positive sign. For operations that produce an External Decimal or
Packed Decimal result, the Data Access Accelerator library inserts the preferred positive sign code of
0xC
if the result is positive, and a preferred negative sign code of 0xD
if the result is
negative. All values between 0x0
and 0xF
inclusive are interpreted as valid sign codes.
This library has full support for signed integers but only limited support for scale points (decimals). Scale points and other unrecognized characters found in input External, Unicode, or Packed Decimal byte arrays are not supported, and may cause IllegalArgumentExceptions or undefined results. BigDecimal inputs will have scale ignored (i.e. -1.23 will be interpreted as -123). When converting to BigDecimal (as output), a scale value may be explicitly specified as a separate parameter.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
External Decimal data format where each byte is an EBCDIC character representing a decimal digit, the sign is encoded in the top nibble of the first byte.static final int
External Decimal data format where each byte is an EBCDIC character representing a decimal digit, the sign is encoded in the top nibble of the last byte.static final int
External Decimal data format where each byte is an EBCDIC character representing a decimal digit, the sign is encoded in a separate byte that comes before the first byte of the number.static final int
External Decimal data format where each byte is an EBCDIC character representing a decimal digit, the sign is encoded in a separate byte that comes after the last byte of the number.static final int
Unicode Decimal data format where each digit is a Unicode character, the sign is stored in the first character.static final int
Unicode Decimal data format where each digit is a Unicode character, the sign is stored in the last character.static final int
Unicode Decimal data format where each digit is a Unicode character, there is no sign. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
convertBigDecimalToExternalDecimal
(BigDecimal bigDecimalValue, byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a BigDecimal value to an External Decimal in a byte array Overflow can happen if the BigDecimal does not fit into the result byte array.static void
convertBigDecimalToPackedDecimal
(BigDecimal bigDecimalValue, byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a BigDecimal into a Packed Decimal in a byte array Overflow can happen if the BigDecimal does not fit into the result byte array.static void
convertBigDecimalToUnicodeDecimal
(BigDecimal bigDecimalValue, char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a BigDecimal value to a Unicode Decimal in a char array Overflow can happen if the BigDecimal does not fit into the result char array.static void
convertBigIntegerToExternalDecimal
(BigInteger bigIntegerValue, byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a BigInteger value into an External Decimal in a byte array Overflow can happen if the BigInteger does not fit into the byte array.static void
convertBigIntegerToPackedDecimal
(BigInteger bigIntegerValue, byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a BigInteger value into a Packed Decimal in a byte array Overflow can happen if the BigInteger does not fit into the byte array.static void
convertBigIntegerToUnicodeDecimal
(BigInteger bigIntegerValue, char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a BigInteger value to a Unicode Decimal in a char array Overflow can happen if the BigInteger does not fit into the char array.static BigDecimal
convertExternalDecimalToBigDecimal
(byte[] externalDecimal, int offset, int precision, int scale, boolean checkOverflow, int decimalType) Converts an External Decimal in a byte array to a BigDecimal.static BigInteger
convertExternalDecimalToBigInteger
(byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Convert an External Decimal in a byte array to a BigInteger.static int
convertExternalDecimalToInteger
(byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts an External Decimal value in a byte array into a binary integer.static long
convertExternalDecimalToLong
(byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts an External Decimal value in a byte array into a long.static void
convertExternalDecimalToPackedDecimal
(byte[] externalDecimal, int externalOffset, byte[] packedDecimal, int packedOffset, int precision, int decimalType) Converts an External Decimal in a byte array to a Packed Decimal in another byte array.static void
convertIntegerToExternalDecimal
(int integerValue, byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts an integer to an External Decimal in a byte array.static void
convertIntegerToPackedDecimal
(int integerValue, byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a binary integer value into a signed Packed Decimal format.static void
convertIntegerToUnicodeDecimal
(int integerValue, char[] unicodeDecimal, int offset, int precision, boolean checkoverflow, int unicodeType) Converts an integer to a Unicode Decimal in a char array Overflow can happen if the resulting External Decimal value does not fit into the char array, given the offset and precision.static void
convertLongToExternalDecimal
(long longValue, byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a long into an External Decimal in a byte array.static void
convertLongToPackedDecimal
(long longValue, byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a binary long value into signed Packed Decimal format.static void
convertLongToUnicodeDecimal
(long longValue, char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a long to a Unicode Decimal in a char array Overflow can happen if the resulting Unicode Decimal value does not fit into the char array, given its precision and offset .static BigDecimal
convertPackedDecimalToBigDecimal
(byte[] packedDecimal, int offset, int precision, int scale, boolean checkOverflow) Convert a Packed Decimal in a byte array to a BigDecimal.static BigInteger
convertPackedDecimalToBigInteger
(byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Convert a Packed Decimal in a byte array to a BigInteger.static void
convertPackedDecimalToExternalDecimal
(byte[] packedDecimal, int packedOffset, byte[] externalDecimal, int externalOffset, int precision, int decimalType) Converts a Packed Decimal in a byte array into an External Decimal in another byte array.static int
convertPackedDecimalToInteger
(byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a Packed Decimal value in a byte array into a binary integer.static long
convertPackedDecimalToLong
(byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a Packed Decimal value in a byte array into a binary long.static void
convertPackedDecimalToUnicodeDecimal
(byte[] packedDecimal, int packedOffset, char[] unicodeDecimal, int unicodeOffset, int precision, int decimalType) Convert a Packed Decimal in a byte array to a Unicode Decimal in a char array.static BigDecimal
convertUnicodeDecimalToBigDecimal
(char[] unicodeDecimal, int offset, int precision, int scale, boolean checkOverflow, int decimalType) Converts a Unicode Decimal in a char array to a BigDecimal.static BigInteger
convertUnicodeDecimalToBigInteger
(char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Convert a Unicode Decimal in a char array to a BigInteger.static int
convertUnicodeDecimalToInteger
(char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int unicodeType) Converts a Unicode Decimal value in a char array into a binary integer.static long
convertUnicodeDecimalToLong
(char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int unicodeType) Converts a Unicode Decimal value in a char array into a binary long.static void
convertUnicodeDecimalToPackedDecimal
(char[] unicodeDecimal, int unicodeOffset, byte[] packedDecimal, int packedOffset, int precision, int decimalType) Converts an Unicode Decimal in a char array to a Packed Decimal in a byte array.
-
Field Details
-
EBCDIC_SIGN_EMBEDDED_TRAILING
public static final int EBCDIC_SIGN_EMBEDDED_TRAILINGExternal Decimal data format where each byte is an EBCDIC character representing a decimal digit, the sign is encoded in the top nibble of the last byte.- See Also:
-
EBCDIC_SIGN_EMBEDDED_LEADING
public static final int EBCDIC_SIGN_EMBEDDED_LEADINGExternal Decimal data format where each byte is an EBCDIC character representing a decimal digit, the sign is encoded in the top nibble of the first byte.- See Also:
-
EBCDIC_SIGN_SEPARATE_TRAILING
public static final int EBCDIC_SIGN_SEPARATE_TRAILINGExternal Decimal data format where each byte is an EBCDIC character representing a decimal digit, the sign is encoded in a separate byte that comes after the last byte of the number.- See Also:
-
EBCDIC_SIGN_SEPARATE_LEADING
public static final int EBCDIC_SIGN_SEPARATE_LEADINGExternal Decimal data format where each byte is an EBCDIC character representing a decimal digit, the sign is encoded in a separate byte that comes before the first byte of the number.- See Also:
-
UNICODE_UNSIGNED
public static final int UNICODE_UNSIGNEDUnicode Decimal data format where each digit is a Unicode character, there is no sign.- See Also:
-
UNICODE_SIGN_SEPARATE_LEADING
public static final int UNICODE_SIGN_SEPARATE_LEADINGUnicode Decimal data format where each digit is a Unicode character, the sign is stored in the first character.- See Also:
-
UNICODE_SIGN_SEPARATE_TRAILING
public static final int UNICODE_SIGN_SEPARATE_TRAILINGUnicode Decimal data format where each digit is a Unicode character, the sign is stored in the last character.- See Also:
-
-
Method Details
-
convertIntegerToPackedDecimal
public static void convertIntegerToPackedDecimal(int integerValue, byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a binary integer value into a signed Packed Decimal format. The Packed Decimal will be padded with zeros on the left if necessary. Overflow can happen if the resulting Packed Decimal does not fit into the result byte array, given the offset and precision. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
integerValue
- the binary integer value to convertpackedDecimal
- byte array that will store the resulting Packed Decimal valueoffset
- offset of the first byte of the Packed Decimal inpackedDecimal
precision
- number of Packed Decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifpackedDecimal
is nullArithmeticException
- if thecheckOverflow
parameter is true and overflow occurs
-
convertIntegerToExternalDecimal
public static void convertIntegerToExternalDecimal(int integerValue, byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts an integer to an External Decimal in a byte array. The External Decimal will be padded with zeros on the left if necessary. Overflow can happen if the resulting External Decimal value does not fit into the byte array, given the precision and offset. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
integerValue
- the value to convertexternalDecimal
- the byte array which will hold the External Decimal on a successful returnoffset
- the offset in the byte array at which the External Decimal should be locatedprecision
- the number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the designated array cannot hold the External Decimal.decimalType
- constant value indicating the type of External Decimal- Throws:
NullPointerException
- ifexternalDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- if thecheckOverflow
parameter is true and overflow occursIllegalArgumentException
- ifdecimalType
orprecision
is invalid
-
convertIntegerToUnicodeDecimal
public static void convertIntegerToUnicodeDecimal(int integerValue, char[] unicodeDecimal, int offset, int precision, boolean checkoverflow, int unicodeType) Converts an integer to a Unicode Decimal in a char array Overflow can happen if the resulting External Decimal value does not fit into the char array, given the offset and precision. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
integerValue
- the long value to convertunicodeDecimal
- the char array which will hold the Unicode Decimal on a successful returnoffset
- the offset in the char array where the Unicode Decimal would be locatedprecision
- the number of decimal digits. Maximum valid precision is 253checkoverflow
- if true, when the designated anArithmeticException
unicodeType
- constant value indicating the type of Unicode Decimal- Throws:
NullPointerException
- ifunicodeDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- if thecheckOverflow
parameter is true and overflow occursIllegalArgumentException
- if thedecimalType
orprecision
is invalid
-
convertLongToPackedDecimal
public static void convertLongToPackedDecimal(long longValue, byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a binary long value into signed Packed Decimal format. The Packed Decimal will be padded with zeros on the left if necessary. Overflow can happen if the resulting Packed Decimal does not fit into the result byte array, given the offset and precision . In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
longValue
- the binary long value to convertpackedDecimal
- byte array that will store the resulting Packed Decimal valueoffset
- offset of the first byte of the Packed Decimal inpackedDecimal
precision
- number of Packed Decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow), otherwise a truncated value is returned- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifpackedDecimal
is nullArithmeticException
- thecheckOverflow
parameter is true and overflow occurs
-
convertLongToExternalDecimal
public static void convertLongToExternalDecimal(long longValue, byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a long into an External Decimal in a byte array. The External Decimal will be padded with zeros on the left if necessary. Overflow can happen if the External Decimal value does not fit into the byte array, given its precision and offset. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
longValue
- the value to convertexternalDecimal
- the byte array which will hold the External Decimal on a successful returnoffset
- the offset intoexternalDecimal
where External Decimal should be locatedprecision
- the number of decimal digits to convert. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
orIllegalArgumentException
may be throwndecimalType
- constant value indicating the type of External Decimal- Throws:
NullPointerException
- ifexternalDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- if thecheckOverflow
parameter is true and overflow occursIllegalArgumentException
- if thedecimalType
orprecision
is invalid
-
convertLongToUnicodeDecimal
public static void convertLongToUnicodeDecimal(long longValue, char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a long to a Unicode Decimal in a char array Overflow can happen if the resulting Unicode Decimal value does not fit into the char array, given its precision and offset . In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
longValue
- the long value to convertunicodeDecimal
- the char array which will hold the Unicode Decimal on a successful returnoffset
- the offset in the char array where the Unicode Decimal would be locatedprecision
- the number of Unicode Decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
orIllegalArgumentException
may be throwndecimalType
- constant value indicating the type of External Decimal- Throws:
NullPointerException
- ifunicodeDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- if thecheckOverflow
parameter is true and overflow occursIllegalArgumentException
- ifdecimalType
orprecision
is invalid
-
convertPackedDecimalToInteger
public static int convertPackedDecimalToInteger(byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a Packed Decimal value in a byte array into a binary integer. If the digital part of the input Packed Decimal is not valid then the digital part of the output will not be valid. The sign of the input Packed Decimal is assumed to be positive unless the sign nibble contains one of the negative sign codes, in which case the sign of the input Packed Decimal is interpreted as negative. Overflow can happen if the Packed Decimal value does not fit into a binary integer. WhencheckOverflow
is true overflow results in anArithmeticException
, when false a truncated or invalid result is returned.- Parameters:
packedDecimal
- byte array which contains the Packed Decimal valueoffset
- offset of the first byte of the Packed Decimal inpackedDecimal
precision
- number of Packed Decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
may be thrown- Returns:
- int the resulting binary integer value
- Throws:
NullPointerException
- ifpackedDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result does not fit into an int (overflow)
-
convertPackedDecimalToLong
public static long convertPackedDecimalToLong(byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a Packed Decimal value in a byte array into a binary long. If the digital part of the input Packed Decimal is not valid then the digital part of the output will not be valid. The sign of the input Packed Decimal is assumed to be positive unless the sign nibble contains one of the negative sign codes, in which case the sign of the input Packed Decimal is interpreted as negative. Overflow can happen if the Packed Decimal value does not fit into a binary long. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
packedDecimal
- byte array which contains the Packed Decimal valueoffset
- offset of the first byte of the Packed Decimal inpackedDecimal
precision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
may be thrown- Returns:
- long the resulting binary long value
- Throws:
NullPointerException
- ifpackedDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result does not fit into a long (overflow)
-
convertPackedDecimalToExternalDecimal
public static void convertPackedDecimalToExternalDecimal(byte[] packedDecimal, int packedOffset, byte[] externalDecimal, int externalOffset, int precision, int decimalType) Converts a Packed Decimal in a byte array into an External Decimal in another byte array. If the digital part of the input Packed Decimal is not valid then the digital part of the output will not be valid. The sign of the input Packed Decimal is assumed to be positive unless the sign nibble contains one of the negative sign codes, in which case the sign of the input Packed Decimal is interpreted as negative.- Parameters:
packedDecimal
- byte array that holds the Packed Decimal to be convertedpackedOffset
- offset inpackedDecimal
where the Packed Decimal is locatedexternalDecimal
- byte array that will hold the External Decimal on a successful returnexternalOffset
- offset inexternalOffset
where the External Decimal is expected to be locatedprecision
- number of decimal digitsdecimalType
- constant indicating the type of the decimal- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifpackedDecimal
orexternalDecimal
are nullIllegalArgumentException
- ifprecision
ordecimalType
is invalid
-
convertPackedDecimalToUnicodeDecimal
public static void convertPackedDecimalToUnicodeDecimal(byte[] packedDecimal, int packedOffset, char[] unicodeDecimal, int unicodeOffset, int precision, int decimalType) Convert a Packed Decimal in a byte array to a Unicode Decimal in a char array. If the digital part of the input Packed Decimal is not valid then the digital part of the output will not be valid. The sign of the input Packed Decimal is assumed to be positive unless the sign nibble contains one of the negative sign codes, in which case the sign of the input Packed Decimal is interpreted as negative.- Parameters:
packedDecimal
- byte array that holds a Packed Decimal to be convertedpackedOffset
- offset inpackedDecimal
where the Packed Decimal is locatedunicodeDecimal
- char array that will hold the Unicode Decimal on a successful returnunicodeOffset
- offset in the byte array where the Unicode Decimal is expected to be locatedprecision
- number of decimal digitsdecimalType
- constant value indicating the type of the External Decimal- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifpackedDecimal
orunicodeDecimal
are nullIllegalArgumentException
- ifprecision
ordecimalType
is invalid
-
convertPackedDecimalToBigInteger
public static BigInteger convertPackedDecimalToBigInteger(byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Convert a Packed Decimal in a byte array to a BigInteger. If the digital part of the input Packed Decimal is not valid then the digital part of the output will not be valid. The sign of the input Packed Decimal is assumed to to be positive unless the sign nibble contains one of the negative sign codes, in which case the sign of the input Packed Decimal is interpreted as negative. Overflow can happen if the Packed Decimal value does not fit into the BigInteger. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
packedDecimal
- byte array that holds the Packed Decimal to be convertedoffset
- offset inpackedDecimal
where the Packed Decimal is locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)- Returns:
- BigInteger the resulting BigInteger
- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifpackedDecimal
is null
-
convertPackedDecimalToBigDecimal
public static BigDecimal convertPackedDecimalToBigDecimal(byte[] packedDecimal, int offset, int precision, int scale, boolean checkOverflow) Convert a Packed Decimal in a byte array to a BigDecimal. If the digital part of the input Packed Decimal is not valid then the digital part of the output will not be valid. The sign of the input Packed Decimal is assumed to to be positive unless the sign nibble contains one of the negative sign codes, in which case the sign of the input Packed Decimal is interpreted as negative. Overflow can happen if the Packed Decimal value does not fit into the BigDecimal. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
packedDecimal
- byte array that holds the Packed Decimal to be convertedoffset
- offset inpackedDecimal
where the Packed Decimal is locatedprecision
- number of decimal digits. Maximum valid precision is 253scale
- scale of the BigDecimal to be returnedcheckOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)- Returns:
- BigDecimal the resulting BigDecimal
- Throws:
NullPointerException
- ifpackedDecimal
is nullArrayIndexOutOfBoundsException
- /requires rounding if an invalid array access occurs
-
convertExternalDecimalToInteger
public static int convertExternalDecimalToInteger(byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts an External Decimal value in a byte array into a binary integer. If the digital part of the input External Decimal is not valid then the digital part of the output will not be valid. The sign of the input External Decimal is assumed to be positive unless the sign nibble or byte (depending ondecimalType
) contains one of the negative sign codes, in which case the sign of the input External Decimal is interpreted as negative. Overflow can happen if the External Decimal value does not fit into a binary integer. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false the resulting number will be wrapped around starting at the minimum/maximum possible integer value.- Parameters:
externalDecimal
- byte array which contains the External Decimal valueoffset
- the offset where the External Decimal value is locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
orIllegalArgumentException
may be thrown. If false and there is an overflow, the result is undefined.decimalType
- constant value indicating the type of External Decimal- Returns:
- int the resulting binary integer
- Throws:
NullPointerException
- ifexternalDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result does not fit into a int (overflow)IllegalArgumentException
- ifprecision
ordecimalType
is invalid
-
convertExternalDecimalToLong
public static long convertExternalDecimalToLong(byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts an External Decimal value in a byte array into a long. If the digital part of the input External Decimal is not valid then the digital part of the output will not be valid. The sign of the input External Decimal is assumed to be positive unless the sign nibble or byte (depending ondecimalType
) contains one of the negative sign codes, in which case the sign of the input External Decimal is interpreted as negative. Overflow can happen if the External Decimal value does not fit into a binary long. WhencheckOverflow
is true overflow results in anArithmeticException
, when false the resulting number will be wrapped around starting at the minimum/maximum possible long value.- Parameters:
externalDecimal
- byte array which contains the External Decimal valueoffset
- offset of the first byte of the Packed Decimal in theexternalDecimal
precision
- number of External Decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown when the converted value cannot fit into designated External Decimal array. If false and there is an overflow, the result is undefined.decimalType
- constant value indicating the type of External Decimal- Returns:
- long the resulting binary long value
- Throws:
NullPointerException
- ifexternalDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result does not fit into a long (overflow)IllegalArgumentException
- ifprecision
ordecimalType
is invalid
-
convertExternalDecimalToPackedDecimal
public static void convertExternalDecimalToPackedDecimal(byte[] externalDecimal, int externalOffset, byte[] packedDecimal, int packedOffset, int precision, int decimalType) Converts an External Decimal in a byte array to a Packed Decimal in another byte array. If the digital part of the input External Decimal is not valid then the digital part of the output will not be valid. The sign of the input External Decimal is assumed to be positive unless the sign nibble or byte (depending ondecimalType
) contains one of the negative sign codes, in which case the sign of the input External Decimal is interpreted as negative.- Parameters:
externalDecimal
- byte array holding the External Decimal to be convertedexternalOffset
- offset inexternalDecimal
where the External Decimal is locatedpackedDecimal
- byte array which will hold the Packed Decimal on a successful returnpackedOffset
- offset inpackedDecimal
where the Packed Decimal is expected to be locatedprecision
- the number of decimal digitsdecimalType
- constant value indicating the type of External Decimal- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifpackedDecimal
orexternalDecimal
is nullIllegalArgumentException
- ifprecision
ordecimalType
is invalid
-
convertExternalDecimalToBigInteger
public static BigInteger convertExternalDecimalToBigInteger(byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Convert an External Decimal in a byte array to a BigInteger. The sign of the input External Decimal is assumed to to be positive unless the sign nibble or byte (depending ondecimalType
) contains one of the negative sign codes, in which case the sign of the input External Decimal is interpreted as negative. Overflow can happen if the External Decimal value does not fit into the BigInteger. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
externalDecimal
- byte array that holds the Packed Decimal to be convertedoffset
- offset inexternalDecimal
where the Packed Decimal is locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)decimalType
- constant value indicating the type of External Decimal- Returns:
- BigInteger the resulting BigInteger
- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifexternalDecimal
is nullArithmeticException
- ifcheckOverflow
is true and the result overflowsIllegalArgumentException
- ifdecimalType
orprecision
is invalid, or the digital part of the input is invalid.
-
convertExternalDecimalToBigDecimal
public static BigDecimal convertExternalDecimalToBigDecimal(byte[] externalDecimal, int offset, int precision, int scale, boolean checkOverflow, int decimalType) Converts an External Decimal in a byte array to a BigDecimal. The sign of the input External Decimal is assumed to be positive unless the sign nibble or byte (depending ondecimalType
) contains one of the negative sign codes, in which case the sign of the input External Decimal is interpreted as negative. Overflow can happen if the External Decimal value does not fit into the BigDecimal. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
externalDecimal
- byte array holding the External Decimal to be convertedoffset
- offset inexternalDecimal
where the External Decimal is locatedprecision
- number of decimal digits. Maximum valid precision is 253scale
- scale of the BigDecimalcheckOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)decimalType
- constant value that indicates the type of External Decimal- Returns:
- BigDecimal the resulting BigDecimal
- Throws:
NullPointerException
- ifexternalDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result overflowsIllegalArgumentException
- ifcheckOverflow
is true and the Packed Decimal is in an invalid format, or the digital part of the input is invalid.
-
convertUnicodeDecimalToInteger
public static int convertUnicodeDecimalToInteger(char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int unicodeType) Converts a Unicode Decimal value in a char array into a binary integer. The sign of the input Unicode Decimal is assumed to be positive unless the sign char contains the negative sign code, in which case the sign of the input Unicode Decimal is interpreted as negative. Overflow can happen if the Unicode Decimal value does not fit into a binary int. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
unicodeDecimal
- char array which contains the Unicode Decimal valueoffset
- the offset where the Unicode Decimal value is locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
orIllegalArgumentException
may be thrownunicodeType
- constant value indicating the type of External Decimal- Returns:
- int the resulting binary integer
- Throws:
NullPointerException
- ifunicodeDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result does not fit into a long (overflow)IllegalArgumentException
- ifprecision
ordecimalType
is invalid, or the digital part of the input is invalid.
-
convertUnicodeDecimalToLong
public static long convertUnicodeDecimalToLong(char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int unicodeType) Converts a Unicode Decimal value in a char array into a binary long. The sign of the input Unicode Decimal is assumed to be positive unless the sign char contains the negative sign code, in which case the sign of the input Unicode Decimal is interpreted as negative. Overflow can happen if the Unicode Decimal value does not fit into a binary long. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
unicodeDecimal
- char array which contains the External Decimal valueoffset
- offset of the first byte of the Unicode Decimal inunicodeDecimal
precision
- number of Unicode Decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown whenunicodeType
- constant value indicating the type of External Decimal- Returns:
- long the resulting binary long value
- Throws:
NullPointerException
- ifunicodeDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result does not fit into a long (overflow)IllegalArgumentException
- ifunicodeType
orprecision
is invalid, or the digital part of the input is invalid.
-
convertUnicodeDecimalToPackedDecimal
public static void convertUnicodeDecimalToPackedDecimal(char[] unicodeDecimal, int unicodeOffset, byte[] packedDecimal, int packedOffset, int precision, int decimalType) Converts an Unicode Decimal in a char array to a Packed Decimal in a byte array. If the digital part of the input Unicode Decimal is not valid then the digital part of the output will not be valid. The sign of the input Unicode Decimal is assumed to be positive unless the sign byte contains the negative sign code, in which case the sign of the input Unicode Decimal is interpreted as negative.- Parameters:
unicodeDecimal
- char array that holds the Unicode Decimal to be convertedunicodeOffset
- offset inunicodeDecimal
at which the Unicode Decimal is locatedpackedDecimal
- byte array that will hold the Packed Decimal on a successful returnpackedOffset
- offset inpackedDecimal
where the Packed Decimal is expected to be locatedprecision
- number of decimal digitsdecimalType
- constant value indicating the type of External Decimal- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifpackedDecimal
orunicodeDecimal
are nullIllegalArgumentException
- ifprecision
ordecimalType
is invalid
-
convertUnicodeDecimalToBigInteger
public static BigInteger convertUnicodeDecimalToBigInteger(char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Convert a Unicode Decimal in a char array to a BigInteger. The sign of the input Unicode Decimal is assumed to be positive unless the sign byte contains the negative sign code, in which case the sign of the input Unicode Decimal is interpreted as negative. Overflow can happen if the Unicode Decimal value does not fit into a binary long. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
unicodeDecimal
- char array that holds the Packed Decimal to be convertedoffset
- offset intounicodeDecimal
where the Packed Decimal is locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)decimalType
- constant value indicating the type of External Decimal- Returns:
- BigInteger the resulting BigInteger
- Throws:
ArrayIndexOutOfBoundsException
- if an invalid array access occursNullPointerException
- ifunicodeDecimal
is nullArithmeticException
- ifcheckOverflow
is true and the result overflowsIllegalArgumentException
- ifdecimalType
orprecision
is invalid, or the digital part of the input is invalid.
-
convertUnicodeDecimalToBigDecimal
public static BigDecimal convertUnicodeDecimalToBigDecimal(char[] unicodeDecimal, int offset, int precision, int scale, boolean checkOverflow, int decimalType) Converts a Unicode Decimal in a char array to a BigDecimal. The sign of the input Unicode Decimal is assumed to to be positive unless the sign byte contains the negative sign code, in which case the sign of the input Unicode Decimal is interpreted as negative. Overflow can happen if the Unicode Decimal value does not fit into the BigDecimal. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
unicodeDecimal
- char array that holds the Unicode Decimaloffset
- offset inunicodeDecimal
where the Unicode Decimal is locatedprecision
- number of decimal digits. Maximum valid precision is 253scale
- scale of the returned BigDecimalcheckOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)decimalType
- constant value indicating the type of External Decimal- Returns:
- BigDecimal
- Throws:
NullPointerException
- ifunicodeDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result overflowsIllegalArgumentException
- ifcheckOverflow
is true and the Packed Decimal is in an invalid format, or the digital part of the input is invalid.
-
convertBigIntegerToPackedDecimal
public static void convertBigIntegerToPackedDecimal(BigInteger bigIntegerValue, byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a BigInteger value into a Packed Decimal in a byte array Overflow can happen if the BigInteger does not fit into the byte array. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
bigIntegerValue
- BigInteger value to be convertedpackedDecimal
- byte array which will hold the Packed Decimal on a successful returnoffset
- offset intopackedDecimal
where the Packed Decimal is expected to be locatedprecision
- number of decimal digits. Maximum valid precision is 253scheckOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)- Throws:
NullPointerException
- ifpackedDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result overflows
-
convertBigIntegerToExternalDecimal
public static void convertBigIntegerToExternalDecimal(BigInteger bigIntegerValue, byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a BigInteger value into an External Decimal in a byte array Overflow can happen if the BigInteger does not fit into the byte array. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
bigIntegerValue
- BigInteger value to be convertedexternalDecimal
- byte array which will hold the External Decimal on a successful returnoffset
- offset intoexternalDecimal
where the External Decimal is expected to be locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)decimalType
- constant value that indicates the type of External Decimal- Throws:
NullPointerException
- ifexternalDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result overflowsIllegalArgumentException
- ifdecimalType
orprecision
is invalid
-
convertBigIntegerToUnicodeDecimal
public static void convertBigIntegerToUnicodeDecimal(BigInteger bigIntegerValue, char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a BigInteger value to a Unicode Decimal in a char array Overflow can happen if the BigInteger does not fit into the char array. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
bigIntegerValue
- BigInteger value to be convertedunicodeDecimal
- char array that will hold the Unicode decimal on a successful returnoffset
- offset intounicodeDecimal
where the Unicode Decimal is expected to be locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)decimalType
- constant indicating the type of External Decimal- Throws:
NullPointerException
- ifunicodeDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result overflowsIllegalArgumentException
- ifdecimalType
orprecision
is invalid
-
convertBigDecimalToPackedDecimal
public static void convertBigDecimalToPackedDecimal(BigDecimal bigDecimalValue, byte[] packedDecimal, int offset, int precision, boolean checkOverflow) Converts a BigDecimal into a Packed Decimal in a byte array Overflow can happen if the BigDecimal does not fit into the result byte array. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
bigDecimalValue
- the BigDecimal value to be convertedpackedDecimal
- byte array which will hold the Packed Decimal on a successful returnoffset
- desired offset inpackedDecimal
where the Packed Decimal is expected to be locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)- Throws:
NullPointerException
- ifpackedDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result overflows
-
convertBigDecimalToExternalDecimal
public static void convertBigDecimalToExternalDecimal(BigDecimal bigDecimalValue, byte[] externalDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a BigDecimal value to an External Decimal in a byte array Overflow can happen if the BigDecimal does not fit into the result byte array. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
bigDecimalValue
- BigDecimal value to be convertedexternalDecimal
- byte array that will hold the External Decimal on a successful returnoffset
- offset inexternalDecimal
where the External Decimal is expected to be locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)decimalType
- constant value indicating the External Decimal type- Throws:
NullPointerException
- ifexternalDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result overflowsIllegalArgumentException
- ifprecision
ordecimalType
is invalid
-
convertBigDecimalToUnicodeDecimal
public static void convertBigDecimalToUnicodeDecimal(BigDecimal bigDecimalValue, char[] unicodeDecimal, int offset, int precision, boolean checkOverflow, int decimalType) Converts a BigDecimal value to a Unicode Decimal in a char array Overflow can happen if the BigDecimal does not fit into the result char array. In this case, whencheckOverflow
is true anArithmeticException
is thrown, when false a truncated or invalid result is returned.- Parameters:
bigDecimalValue
- BigDecimal value to be convertedunicodeDecimal
- char array which will hold the Unicode Decimal on a successful returnoffset
- offset inunicodeDecimal
where the Unicode Decimal is expected to be locatedprecision
- number of decimal digits. Maximum valid precision is 253checkOverflow
- if true anArithmeticException
will be thrown if the decimal value does not fit in the specified precision (overflow)decimalType
- constant value that indicates the type of External Decimal- Throws:
NullPointerException
- ifunicodeDecimal
is nullArrayIndexOutOfBoundsException
- if an invalid array access occursArithmeticException
- ifcheckOverflow
is true and the result overflowsIllegalArgumentException
- ifdecimalType
orprecision
is invalid
-