public final class PackedDecimal extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addPackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
Add two Packed Decimals in byte arrays.
|
static int |
checkPackedDecimal(byte[] byteArray,
int offset,
int precision)
Checks the validity of a Packed Decimal, return code indicating the status of the Packed Decimal.
|
static int |
checkPackedDecimal(byte[] byteArray,
int offset,
int precision,
boolean ignoreHighNibbleForEvenPrecision)
Checks the validity of a Packed Decimal, return code indicating the status of the Packed Decimal.
|
static int |
checkPackedDecimal(byte[] byteArray,
int offset,
int precision,
boolean ignoreHighNibbleForEvenPrecision,
boolean canOverwriteHighNibbleForEvenPrecision)
Checks the validity of a Packed Decimal, return code indicating the status of the Packed Decimal.
|
static void |
dividePackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
Divides two Packed Decimals is byte arrays.
|
static boolean |
equalsPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
Checks if the two Packed Decimal operands are equal.
|
static boolean |
greaterThanOrEqualsPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
Checks if the first Packed Decimal operand is greater than or equal to the second one.
|
static boolean |
greaterThanPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
Checks if the first Packed Decimal operand is greater than the second one.
|
static boolean |
lessThanOrEqualsPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
Checks if the first Packed Decimal operand is less than or equal to the second one.
|
static boolean |
lessThanPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
Checks if the first Packed Decimal operand is lesser than the second one.
|
static void |
movePackedDecimal(byte[] destination,
int destinationOffset,
int destinationPrecision,
byte[] source,
int sourceOffset,
int sourcePrecision,
boolean checkOverflow)
Creates a copy of a Packed Decimal.
|
static void |
multiplyPackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
Multiplies two Packed Decimals in byte arrays.
|
static boolean |
notEqualsPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
Checks if the two Packed Decimal operands are unequal.
|
static void |
remainderPackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
Calculates the remainder resulting from the division of two Packed Decimals in byte arrays.
|
static void |
setPackedZero(byte[] byteArray,
int offset,
int len)
Create a positive Packed Decimal representation of zero.
|
static void |
shiftLeftPackedDecimal(byte[] destination,
int destinationOffset,
int destinationPrecision,
byte[] source,
int sourceOffset,
int sourcePrecision,
int shiftAmount,
boolean checkOverflow)
Left shift a Packed Decimal appending zeros to the right.
|
static void |
shiftRightPackedDecimal(byte[] destination,
int destinationOffset,
int destinationPrecision,
byte[] source,
int sourceOffset,
int sourcePrecision,
int shiftAmount,
boolean round,
boolean checkOverflow)
Right shift, and optionally round, a Packed Decimal.
|
static void |
subtractPackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
Subtracts two Packed Decimals in byte arrays.
|
public static int checkPackedDecimal(byte[] byteArray,
int offset,
int precision,
boolean ignoreHighNibbleForEvenPrecision,
boolean canOverwriteHighNibbleForEvenPrecision)
byteArray - the source container arrayoffset - starting offset of the Packed Decimalprecision - precision of the Packed Decimal. Maximum valid precision is 253ignoreHighNibbleForEvenPrecision - if true, ignore to check if the top nibble (first 4 bits) of the input is an invalid sign value in the
case of even precisioncanOverwriteHighNibbleForEvenPrecision - if true, change the high nibble to a zero in case of even precisionNullPointerException - if byteArray is nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static int checkPackedDecimal(byte[] byteArray,
int offset,
int precision,
boolean ignoreHighNibbleForEvenPrecision)
byteArray - the source container arrayoffset - starting offset of the Packed Decimalprecision - precision of the Packed DecimalignoreHighNibbleForEvenPrecision - if true, ignore the high nibble in the case of even precisionNullPointerException - if byteArray is nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static int checkPackedDecimal(byte[] byteArray,
int offset,
int precision)
byteArray - the source container arrayoffset - starting offset of the Packed Decimalprecision - precision of the Packed DecimalNullPointerException - if byteArray is nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static void addPackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
throws ArithmeticException
result - byte array that will hold the sum of the two operand Packed DecimalsresultOffset - offset into result where the sum Packed Decimal beginsresultPrecision - number of Packed Decimal digits for the sum. Maximum valid precision is 253op1Decimal - byte array that holds the first operand Packed Decimal.op1Offset - offset into op1Decimal where the Packed Decimal. is locatedop1Precision - number of Packed Decimal digits for the first operand. Maximum valid precision is 253op2Decimal - byte array that holds the second operand Packed Decimalop2Offset - offset into op2Decimal where the Packed Decimal is locatedop2Precision - number of Packed Decimal digits for the second operand. Maximum valid precision is 253checkOverflow - check for overflowNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occursArithmeticException - if an overflow occurs during the computation of the sumpublic static void subtractPackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
throws ArithmeticException
result - byte array that will hold the difference of the two operand Packed DecimalsresultOffset - offset into result where the result Packed Decimal is locatedresultPrecision - number of Packed Decimal digits for the result. Maximum valid precision is 253op1Decimal - byte array that holds the first Packed Decimal operandop1Offset - offset into op1Decimal where the first operand is locatedop1Precision - number of Packed Decimal digits for the first operand. Maximum valid precision is 253op2Decimal - byte array that holds the second Packed Decimal operandop2Offset - offset into op2Decimal where the second operand is locatedop2Precision - number of Packed Decimal digits for the second operand. Maximum valid precision is 253checkOverflow - check for overflowNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occursArithmeticException - if an overflow occurs during the computation of the differencepublic static void setPackedZero(byte[] byteArray,
int offset,
int len)
byteArray - byte array which will hold the packed zerooffset - offset into toBytes where the packed zero beginslen - length of the packed zero. Maximum valid length is 253NullPointerException - if toBytes is nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static void multiplyPackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
result - byte array that will hold the product Packed DecimalresultOffset - offset into result where the product Packed Decimal is locatedresultPrecision - the length (number of digits) of the product Packed Decimal. Maximum valid precision is 253op1Decimal - byte array that will hold the multiplicand Packed Decimalop1Offset - offset into op1Decimal where the multiplicand is locatedop1Precision - the length (number of digits) of the multiplicand Packed Decimal. Maximum valid precision is 253op2Decimal - byte array that will hold the multiplierop2Offset - offset into op2Decimal where the multiplier is locatedop2Precision - the length (number of digits) of the multiplier Packed Decimal. Maximum valid precision is 253checkOverflow - if set to true, Packed Decimals are validated before multiplication and an
IllegalArgumentException or ArithmeticException may be thrown. If not, the
result can be invalidNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occursIllegalArgumentException - if an overflow occurs during multiplicationArithmeticException - if any of the Packed Decimal operands are invalidpublic static void dividePackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
result - byte array that will hold the quotient Packed DecimalresultOffset - offset into result where the quotient Packed Decimal is locatedresultPrecision - the length (number of digits) of the quotient Packed Decimal. Maximum valid precision is 253op1Decimal - byte array that will hold the dividend Packed Decimalop1Offset - offset into op1Decimal where the dividend is locatedop1Precision - the length (number of digits) of the dividend Packed Decimal. Maximum valid precision is 253op2Decimal - byte array that will hold the divisorop2Offset - offset into op2Decimal where the divisor is locatedop2Precision - the length (number of digits) of the divisor Packed Decimal. Maximum valid precision is 253checkOverflow - if set to true, Packed Decimals are validated before division and an
IllegalArgumentException or ArithmeticException may be thrown. If not, the
result can be invalidNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occursIllegalArgumentException - if an overflow occurs during divisionArithmeticException - if any of the Packed Decimal operands are invalidpublic static void remainderPackedDecimal(byte[] result,
int resultOffset,
int resultPrecision,
byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision,
boolean checkOverflow)
result - byte array that will hold the remainder Packed DecimalresultOffset - offset into result where the remainder Packed Decimal is locatedresultPrecision - number of Packed Decimal digits for the remainder. Maximum valid precision is 253op1Decimal - byte array that will hold the dividend Packed Decimalop1Offset - offset into op1Decimal where the dividend is locatedop1Precision - number of Packed Decimal digits for the dividend. Maximum valid precision is 253op2Decimal - byte array that will hold the divisorop2Offset - offset into op2Decimal where the divisor is locatedop2Precision - number of Packed Decimal digits for the divisor. Maximum valid precision is 253checkOverflow - if set to true, Packed Decimals are validated before division and an
IllegalArgumentException or ArithmeticException may be thrown. If not, the
result can be invalidNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occursIllegalArgumentException - if an overflow occurs during divisionArithmeticException - if any of the Packed Decimal operands are invalidpublic static boolean lessThanPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
op1Decimal - byte array that holds the first Packed Decimal operandop1Offset - offset into op1Decimal where the first operand is locatedop1Precision - number of Packed Decimal digits for the first operandop2Decimal - byte array that holds the second Packed Decimal operandop2Offset - offset into op2Decimal where the second operand is locatedop2Precision - number of Packed Decimal digits for the second operandop1Decimal < op2Decimal, false otherwiseNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static boolean lessThanOrEqualsPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
op1Decimal - byte array that holds the first Packed Decimal operandop1Offset - offset into op1Decimal where the first operand is locatedop1Precision - number of Packed Decimal digits for the first operandop2Decimal - byte array that holds the second Packed Decimal operandop2Offset - offset into op2Decimal where the second operand is locatedop2Precision - number of Packed Decimal digits for the second operandop1Decimal <= op2Decimal, false otherwiseNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static boolean greaterThanPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
op1Decimal - byte array that holds the first Packed Decimal operandop1Offset - offset into op1Decimal where the first operand is locatedop1Precision - number of Packed Decimal digits for the first operandop2Decimal - byte array that holds the second Packed Decimal operandop2Offset - offset into op2Decimal where the second operand is locatedop2Precision - number of Packed Decimal digits for the second operandop1Decimal > op2Decimal, false otherwiseNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static boolean greaterThanOrEqualsPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
op1Decimal - byte array that holds the first Packed Decimal operandop1Offset - offset into op1Decimal where the first operand is locatedop1Precision - number of Packed Decimal digits for the first operandop2Decimal - byte array that holds the second Packed Decimal operandop2Offset - offset into op2Decimal where the second operand is locatedop2Precision - number of Packed Decimal digits for the second operandop1Decimal >= op2Decimal, false otherwiseNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static boolean equalsPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
op1Decimal - byte array that holds the first Packed Decimal operandop1Offset - offset into op1Decimal where the first operand is locatedop1Precision - number of Packed Decimal digits for the first operandop2Decimal - byte array that holds the second Packed Decimal operandop2Offset - offset into op2Decimal where the second operand is locatedop2Precision - number of Packed Decimal digits for the second operandNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static boolean notEqualsPackedDecimal(byte[] op1Decimal,
int op1Offset,
int op1Precision,
byte[] op2Decimal,
int op2Offset,
int op2Precision)
op1Decimal - byte array that holds the first Packed Decimal operandop1Offset - offset into op1Decimal where the first operand is locatedop1Precision - number of Packed Decimal digits for the first operandop2Decimal - byte array that holds the second Packed Decimal operandop2Offset - offset into op2Decimal where the second operand is locatedop2Precision - number of Packed Decimal digits for the second operandNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occurspublic static void shiftRightPackedDecimal(byte[] destination,
int destinationOffset,
int destinationPrecision,
byte[] source,
int sourceOffset,
int sourcePrecision,
int shiftAmount,
boolean round,
boolean checkOverflow)
destination - byte array that holds the result of the right shift (and rounding)destinationOffset - offset into destination where the result Packed Decimal is locateddestinationPrecision - number of Packed Decimal digits in the destinationsource - byte array that holds the Packed Decimal operand to be right shiftedsourceOffset - offset into source where the operand is locatedsourcePrecision - number of Packed Decimal digits in the operandshiftAmount - amount by which the source will be right shiftedround - if set to true, causes rounding to occurcheckOverflow - if set to true, check for overflowNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occursArithmeticException - if a decimal overflow occursIllegalArgumentException - if the shiftAmount or sourcePrecision parameter is invalid or
the source packed decimal contains invalid sign or digit codepublic static void shiftLeftPackedDecimal(byte[] destination,
int destinationOffset,
int destinationPrecision,
byte[] source,
int sourceOffset,
int sourcePrecision,
int shiftAmount,
boolean checkOverflow)
destination - byte array that holds the result of the left shiftdestinationOffset - offset into destination where the result Packed Decimal is locateddestinationPrecision - number of Packed Decimal digits in the destinationsource - byte array that holds the Packed Decimal operand to be left shiftedsourceOffset - offset into source where the operand is locatedsourcePrecision - number of Packed Decimal digits in the operandshiftAmount - amount by which the source will be left shiftedcheckOverflow - if set to true, check for overflowNullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occursArithmeticException - if a decimal overflow occursIllegalArgumentException - if the shiftAmount or sourcePrecision parameter is invalid or
the source packed decimal contains invalid sign or digit codepublic static void movePackedDecimal(byte[] destination,
int destinationOffset,
int destinationPrecision,
byte[] source,
int sourceOffset,
int sourcePrecision,
boolean checkOverflow)
destination - byte array representing the destinationdestinationOffset - offset into destination destination where the Packed Decimal is locateddestinationPrecision - number of Packed Decimal digits for the destinationsource - byte array which holds the source Packed DecimalsourceOffset - offset into source where the Packed Decimal is locatedsourcePrecision - number of Packed Decimal digits for the source. Maximum valid precision is 253checkOverflow - if set to true, moved Packed Decimals are validated, and an IllegalArgumentException or
ArithmeticException is thrown if non-zero nibbles are truncated during the move
operation. If set to false, no validating is conducted.NullPointerException - if any of the byte arrays are nullArrayIndexOutOfBoundsException - if an invalid array access occursIllegalArgumentException - if the source Packed Decimal is invalidArithmeticException - if a decimal overflow occursEclipse OpenJ9 website.
To raise a bug report or suggest an improvement create an Eclipse OpenJ9 issue.
Copyright © 2013, 2025 IBM Corp. and others.