java.lang.Object
com.pervasive.datarush.commons.util.BigNumberUtil
Miscellaneous BigInteger and BigDecimal utilities
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigIntegerstatic final BigIntegerstatic final BigDecimalstatic final BigDecimalstatic final BigDecimalstatic final BigDecimalstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigInteger -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimaldivide(BigDecimal bigNumerator, long denominator) Divides a BigDecimal by a long while preserving scale.static BigDecimaldivide(BigDecimal bigNumerator, BigDecimal bigDenominator) Divides a BigDecimal by a BigDecimal.static BigDecimaldivide(BigDecimal bigNumerator, BigDecimal bigDenominator, MathContext context) Divides a BigDecimal by a BigDecimal.static booleanisInByteRange(Number number) Checks to see if a number is in the valid range for a Byte type.static booleanisInDoubleRange(Number number) Checks to see if a number is in the valid range for a Double type.static booleanisInFloatRange(Number number) Checks to see if a number is in the valid range for a Float type.static booleanisInIntegerRange(Number number) Checks to see if a number is in the valid range for a Integer type.static booleanisInLongRange(Number number) Checks to see if a number is in the valid range for a Long type.static booleanisInRange(Number number, BigDecimal min, BigDecimal max) Checks to see if a number is within the specified range.static booleanisInRange(Number number, BigInteger min, BigInteger max) Checks to see if a number is within the specified range.static booleanisInShortRange(Number number) Checks to see if a number is in the valid range for a Short type.static BigDecimalremainder(BigDecimal bigNumerator, BigDecimal bigDenominator) Divides a BigDecimal by a BigDecimal and returns the remainder.static BigDecimalremainder(BigDecimal bigNumerator, BigDecimal bigDenominator, MathContext context) Divides a BigDecimal by a BigDecimal and returns the remainder.static BigDecimalroot(BigDecimal num, int n, MathContext baseMC) Calculates the nth root of a BigDecimal.static BigDecimalsqrt(BigDecimal num, MathContext baseMC) Calculates the square root of a BigDecimal.
-
Field Details
-
BYTE_MIN
-
BYTE_MAX
-
SHORT_MIN
-
SHORT_MAX
-
INTEGER_MIN
-
INTEGER_MAX
-
LONG_MIN
-
LONG_MAX
-
FLOAT_MIN
-
FLOAT_MAX
-
DOUBLE_MIN
-
DOUBLE_MAX
-
-
Method Details
-
isInByteRange
Checks to see if a number is in the valid range for a Byte type.- Parameters:
number- the number to check- Returns:
- true if in range
-
isInShortRange
Checks to see if a number is in the valid range for a Short type.- Parameters:
number- the number to check- Returns:
- true if in range
-
isInIntegerRange
Checks to see if a number is in the valid range for a Integer type.- Parameters:
number- the number to check- Returns:
- true if in range
-
isInLongRange
Checks to see if a number is in the valid range for a Long type.- Parameters:
number- the number to check- Returns:
- true if in range
-
isInFloatRange
Checks to see if a number is in the valid range for a Float type.- Parameters:
number- the number to check- Returns:
- true if in range
-
isInDoubleRange
Checks to see if a number is in the valid range for a Double type.- Parameters:
number- the number to check- Returns:
- true if in range
-
isInRange
Checks to see if a number is within the specified range.- Parameters:
number- the number to checkmin- the inclusive minimum of the rangemax- the inclusive maximum of the range- Returns:
- true if in range
-
isInRange
Checks to see if a number is within the specified range.- Parameters:
number- the number to checkmin- the inclusive minimum of the rangemax- the inclusive maximum of the range- Returns:
- true if in range
-
divide
Divides a BigDecimal by a long while preserving scale.- Parameters:
bigNumerator- the BigDecimal to dividedenominator- value to divide by- Returns:
- the quotient of the division
-
divide
Divides a BigDecimal by a BigDecimal. This method will return null if the divisor is zero.- Parameters:
bigNumerator- the dividendbigDenominator- the divisor- Returns:
- the quotient of the division
-
divide
public static BigDecimal divide(BigDecimal bigNumerator, BigDecimal bigDenominator, MathContext context) Divides a BigDecimal by a BigDecimal. This method will return null if the divisor is zero.- Parameters:
bigNumerator- the dividendbigDenominator- the divisorcontext- the context to use- Returns:
- the quotient of the division
-
remainder
Divides a BigDecimal by a BigDecimal and returns the remainder. This method will return null if the divisor is zero.- Parameters:
bigNumerator- the dividendbigDenominator- the divisor- Returns:
- the remainder of the division
-
remainder
public static BigDecimal remainder(BigDecimal bigNumerator, BigDecimal bigDenominator, MathContext context) Divides a BigDecimal by a BigDecimal and returns the remainder. This method will return null if the divisor is zero.- Parameters:
bigNumerator- the dividendbigDenominator- the divisorcontext- the context to use- Returns:
- the remainder of the division
-
sqrt
Calculates the square root of a BigDecimal.- Parameters:
num- a valuebaseMC- the math context to use- Returns:
- the square root of num
-
root
Calculates the nth root of a BigDecimal.- Parameters:
num- a valuen- the rootbaseMC- the math context to use- Returns:
- the nth root of num
-