public class BigDecimalUtils
extends java.lang.Object
BigDecimal.| Modifier and Type | Field and Description |
|---|---|
static java.math.BigDecimal |
PI
the value of PI
|
| Modifier and Type | Method and Description |
|---|---|
static int |
compare(java.math.BigDecimal n1,
java.math.BigDecimal n2,
int p)
Compare two
BigDecimals up to a precision. |
static boolean |
equals(java.math.BigDecimal n1,
java.math.BigDecimal n2,
int precision)
Check if two
BigDecimals are equal up to a precision. |
static java.math.BigDecimal |
exp(java.math.BigDecimal x)
Compute ex.
|
static java.math.BigDecimal |
exp(java.math.BigDecimal x,
int scale)
Compute ex.
|
static java.math.BigDecimal |
exp(double x)
Compute ex.
|
static java.math.BigDecimal |
exp(double x,
int scale)
Compute ex.
|
static java.math.BigDecimal |
getFractional(java.math.BigDecimal num)
Get the fractional part of a number.
|
static java.math.BigDecimal |
getWhole(java.math.BigDecimal num)
Get the integral part of a number (discarding the fractional part).
|
static java.math.BigDecimal |
log(java.math.BigDecimal x)
Compute log(x).
|
static java.math.BigDecimal |
log(java.math.BigDecimal x,
int scale)
Compute log(x) up to a scale.
|
static java.math.BigDecimal |
pow(java.math.BigDecimal a,
java.math.BigDecimal b)
Compute a to the power of b.
|
static java.math.BigDecimal |
pow(java.math.BigDecimal a,
java.math.BigDecimal b,
int scale)
Compute a to the power of b.
|
static java.math.BigDecimal |
pow(java.math.BigDecimal a,
int n)
Compute a to the power of n, where n is an integer.
|
static java.math.BigDecimal |
pow(java.math.BigDecimal a,
int n,
int scale)
Compute a to the power of n, where n is an integer.
|
static java.math.BigDecimal |
sum(java.math.BigDecimal... big)
Sum up the
BigDecimal numbers. |
static java.math.BigDecimal |
sum(double... big)
Sum up big numbers.
|
public static final java.math.BigDecimal PI
public static int compare(java.math.BigDecimal n1,
java.math.BigDecimal n2,
int p)
BigDecimals up to a precision.
In other words, if the absolute difference between the two numbers falls below a threshold, they are considered equal.n1 - a BigDecimaln2 - a BigDecimalp - the threshold is 1e-pn1 is numerically less than, equal to, or greater than n2, respectivelypublic static boolean equals(java.math.BigDecimal n1,
java.math.BigDecimal n2,
int precision)
BigDecimals are equal up to a precision.n1 - a BigDecimaln2 - a BigDecimalprecision - the threshold is 1e-ptrue if the numbers are equal up to a precisionpublic static java.math.BigDecimal sum(java.math.BigDecimal... big)
BigDecimal numbers.big - BigDecimal numberspublic static java.math.BigDecimal sum(double... big)
big - numberspublic static java.math.BigDecimal getWhole(java.math.BigDecimal num)
num - a BigDecimalpublic static java.math.BigDecimal getFractional(java.math.BigDecimal num)
num - a BigDecimalpublic static java.math.BigDecimal pow(java.math.BigDecimal a,
java.math.BigDecimal b)
a - a baseb - an exponentpublic static java.math.BigDecimal pow(java.math.BigDecimal a,
java.math.BigDecimal b,
int scale)
a - a baseb - an exponentscale - a precision parameter as in BigDecimalpublic static java.math.BigDecimal pow(java.math.BigDecimal a,
int n)
a - a basen - an integer exponentpublic static java.math.BigDecimal pow(java.math.BigDecimal a,
int n,
int scale)
BigDecimal.pow(int) but handles also negative exponents.
Use BigDecimal.pow(int) for arbitrary precision if the exponent is positive.a - a basen - an exponentscale - a precision parameter as in BigDecimalpublic static java.math.BigDecimal log(java.math.BigDecimal x)
x - a numberpublic static java.math.BigDecimal log(java.math.BigDecimal x,
int scale)
x - a numberscale - a precision parameter as in BigDecimalpublic static java.math.BigDecimal exp(double x)
x - the exponentpublic static java.math.BigDecimal exp(double x,
int scale)
x - the exponentscale - a precision parameter as in BigDecimalpublic static java.math.BigDecimal exp(java.math.BigDecimal x)
x - the exponentpublic static java.math.BigDecimal exp(java.math.BigDecimal x,
int scale)
x - the exponentscale - a precision parameter as in BigDecimal