Class BigDecimalMath
BigDecimal
s.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BigDecimal
private static BigDecimal
private static final Object
private static final int
private static BigDecimal[]
private static BigDecimal
private static final Object
private static BigDecimal
private static final Object
private static BigDecimal
private static final Object
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static BigDecimal
private static final Object
private static final BigDecimal
private static final Map
<Integer, List<BigDecimal>> private static final Object
private static final BigDecimal
private static final BigDecimal
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimal
acos
(BigDecimal x, MathContext mathContext) Calculates the arc cosine (inverted cosine) ofBigDecimal
x.static BigDecimal
acosh
(BigDecimal x, MathContext mathContext) Calculates the arc hyperbolic cosine (inverse hyperbolic cosine) ofBigDecimal
x.static BigDecimal
acot
(BigDecimal x, MathContext mathContext) Calculates the inverse cotangens (arc cotangens) ofBigDecimal
x.static BigDecimal
acoth
(BigDecimal x, MathContext mathContext) Calculates the arc hyperbolic cotangens (inverse hyperbolic cotangens) ofBigDecimal
x.private static int
adjustScale
(int scale, long exp) static BigDecimal
asin
(BigDecimal x, MathContext mathContext) Calculates the arc sine (inverted sine) ofBigDecimal
x.static BigDecimal
asinh
(BigDecimal x, MathContext mathContext) Calculates the arc hyperbolic sine (inverse hyperbolic sine) ofBigDecimal
x.static BigDecimal
atan
(BigDecimal x, MathContext mathContext) Calculates the arc tangens (inverted tangens) ofBigDecimal
x.static BigDecimal
atan2
(BigDecimal y, BigDecimal x, MathContext mathContext) Calculates the arc tangens (inverted tangens) ofBigDecimal
y / x in the range -pi to pi.static BigDecimal
atanh
(BigDecimal x, MathContext mathContext) Calculates the arc hyperbolic tangens (inverse hyperbolic tangens) ofBigDecimal
x.static BigDecimal
bernoulli
(int n, MathContext mathContext) Calculates the Bernoulli number for the specified index.private static void
checkMathContext
(MathContext mathContext) static BigDecimal
cos
(BigDecimal x, MathContext mathContext) Calculates the cosine (cosinus) ofBigDecimal
x.static BigDecimal
cosh
(BigDecimal x, MathContext mathContext) Calculates the hyperbolic cosine ofBigDecimal
x.static BigDecimal
cot
(BigDecimal x, MathContext mathContext) Calculates the cotangens ofBigDecimal
x.static BigDecimal
coth
(BigDecimal x, MathContext mathContext) Calculates the hyperbolic cotangens ofBigDecimal
x.static BigDecimal
e
(MathContext mathContext) Returns the number e.static BigDecimal
exp
(BigDecimal x, MathContext mathContext) Calculates the natural exponent ofBigDecimal
x (ex).private static BigDecimal
expIntegralFractional
(BigDecimal x, MathContext mathContext) static int
exponent
(BigDecimal value) Returns the exponent of the specifiedBigDecimal
written as mantissa * 10exponent.private static BigDecimal
expTaylor
(BigDecimal x, MathContext mathContext) static BigDecimal
factorial
(int n) Calculates the factorial of the specified integer argument.static BigDecimal
factorial
(BigDecimal x, MathContext mathContext) Calculates the factorial of the specifiedBigDecimal
.private static BigDecimal
factorialLoop
(int n1, int n2) private static BigDecimal
factorialRecursion
(int n1, int n2) static BigDecimal
fractionalPart
(BigDecimal value) Returns the fractional part of the specifiedBigDecimal
(right of the decimal point).static BigDecimal
gamma
(BigDecimal x, MathContext mathContext) Calculates the gamma function of the specifiedBigDecimal
.(package private) static List
<BigDecimal> getSpougeFactorialConstants
(int a) static BigDecimal
integralPart
(BigDecimal value) Returns the integral part of the specifiedBigDecimal
(left of the decimal point).static boolean
isDoubleValue
(BigDecimal value) Returns whether the specifiedBigDecimal
value can be represented asdouble
.static boolean
isIntValue
(BigDecimal value) Returns whether the specifiedBigDecimal
value can be represented asint
.static boolean
isLongValue
(BigDecimal value) Returns whether the specifiedBigDecimal
value can be represented aslong
.static BigDecimal
log
(BigDecimal x, MathContext mathContext) Calculates the natural logarithm ofBigDecimal
x.static BigDecimal
log10
(BigDecimal x, MathContext mathContext) Calculates the logarithm ofBigDecimal
x to the base 10.static BigDecimal
log2
(BigDecimal x, MathContext mathContext) Calculates the logarithm ofBigDecimal
x to the base 2.private static BigDecimal
logTen
(MathContext mathContext) private static BigDecimal
logThree
(MathContext mathContext) private static BigDecimal
logTwo
(MathContext mathContext) private static BigDecimal
logUsingExponent
(BigDecimal x, MathContext mathContext) private static BigDecimal
logUsingNewton
(BigDecimal x, MathContext mathContext) private static BigDecimal
logUsingTwoThree
(BigDecimal x, MathContext mathContext) static BigDecimal
mantissa
(BigDecimal value) Returns the mantissa of the specifiedBigDecimal
written as mantissa * 10exponent.static BigDecimal
pi
(MathContext mathContext) Returns the number pi.private static BigDecimal
piChudnovski
(MathContext mathContext) static BigDecimal
pow
(BigDecimal x, long y, MathContext mathContext) CalculatesBigDecimal
x to the power oflong
y (xy).static BigDecimal
pow
(BigDecimal x, BigDecimal y, MathContext mathContext) CalculatesBigDecimal
x to the power ofBigDecimal
y (xy).private static BigDecimal
powInteger
(BigDecimal x, BigDecimal integerY, MathContext mathContext) CalculatesBigDecimal
x to the power of the integer value y (xy).static BigDecimal
reciprocal
(BigDecimal x, MathContext mathContext) Calculates the reciprocal of the specifiedBigDecimal
.static BigDecimal
root
(BigDecimal x, BigDecimal n, MathContext mathContext) Calculates the n'th root ofBigDecimal
x.private static BigDecimal
rootUsingNewtonRaphson
(BigDecimal x, BigDecimal n, BigDecimal initialResult, MathContext mathContext) static BigDecimal
round
(BigDecimal value, MathContext mathContext) Rounds the specifiedBigDecimal
to the precision of the specifiedMathContext
.static BigDecimal
roundWithTrailingZeroes
(BigDecimal value, MathContext mathContext) Rounds the specifiedBigDecimal
to the precision of the specifiedMathContext
including trailing zeroes.static int
significantDigits
(BigDecimal value) Returns the number of significant digits of the specifiedBigDecimal
.static BigDecimal
sin
(BigDecimal x, MathContext mathContext) Calculates the sine (sinus) ofBigDecimal
x.static BigDecimal
sinh
(BigDecimal x, MathContext mathContext) Calculates the hyperbolic sine ofBigDecimal
x.static BigDecimal
sqrt
(BigDecimal x, MathContext mathContext) Calculates the square root ofBigDecimal
x.static BigDecimal
tan
(BigDecimal x, MathContext mathContext) Calculates the tangens ofBigDecimal
x.static BigDecimal
tanh
(BigDecimal x, MathContext mathContext) Calculates the hyperbolic tangens ofBigDecimal
x.static BigDecimal
toBigDecimal
(String string) Creates aBigDecimal
from the specifiedString
representation.static BigDecimal
toBigDecimal
(String string, MathContext mathContext) Creates aBigDecimal
from the specifiedString
representation.(package private) static BigDecimal
toBigDecimal
(String string, MathContext mathContext, int splitLength) private static BigDecimal
toBigDecimalRecursive
(char[] chars, int offset, int length, int scale, int splitLength) static BigDecimal
toDegrees
(BigDecimal x, MathContext mathContext) Converts an angle measured in radians to an approximately equivalent angle measured in degrees.static BigDecimal
toRadians
(BigDecimal x, MathContext mathContext) /** Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
-
Field Details
-
TWO
-
THREE
-
MINUS_ONE
-
ONE_HALF
-
ONE_HUNDRED_EIGHTY
-
DOUBLE_MAX_VALUE
-
log2Cache
-
log2CacheLock
-
log3Cache
-
log3CacheLock
-
log10Cache
-
log10CacheLock
-
piCache
-
piCacheLock
-
eCache
-
eCacheLock
-
ROUGHLY_TWO_PI
-
EXPECTED_INITIAL_PRECISION
private static final int EXPECTED_INITIAL_PRECISION- See Also:
-
factorialCache
-
spougeFactorialConstantsCache
-
spougeFactorialConstantsCacheLock
-
-
Constructor Details
-
BigDecimalMath
private BigDecimalMath()
-
-
Method Details
-
toBigDecimal
Creates aBigDecimal
from the specifiedString
representation.This method is equivalent to the String constructor
BigDecimal(String)
but has been optimized for large strings (several thousand digits).- Parameters:
string
- the String representation- Returns:
- the created
BigDecimal
- Throws:
NumberFormatException
- ifstring
is not a valid representation of aBigDecimal
- See Also:
-
toBigDecimal
Creates aBigDecimal
from the specifiedString
representation.This method is equivalent to the String constructor
BigDecimal(String, MathContext)
but has been optimized for large strings (several thousand digits).- Parameters:
string
- the string representationmathContext
- theMathContext
used for the result- Returns:
- the created
BigDecimal
- Throws:
NumberFormatException
- ifstring
is not a valid representation of aBigDecimal
ArithmeticException
- if the result is inexact but the rounding mode isUNNECESSARY
- See Also:
-
toBigDecimal
-
adjustScale
private static int adjustScale(int scale, long exp) -
toBigDecimalRecursive
private static BigDecimal toBigDecimalRecursive(char[] chars, int offset, int length, int scale, int splitLength) -
isIntValue
Returns whether the specifiedBigDecimal
value can be represented asint
.If this returns
true
you can callBigDecimal.intValueExact()
without fear of anArithmeticException
.- Parameters:
value
- theBigDecimal
to check- Returns:
true
if the value can be represented asint
value
-
isLongValue
Returns whether the specifiedBigDecimal
value can be represented aslong
.If this returns
true
you can callBigDecimal.longValueExact()
without fear of anArithmeticException
.- Parameters:
value
- theBigDecimal
to check- Returns:
true
if the value can be represented aslong
value
-
isDoubleValue
Returns whether the specifiedBigDecimal
value can be represented asdouble
.If this returns
true
you can callBigDecimal.doubleValue()
without fear of gettingDouble.POSITIVE_INFINITY
orDouble.NEGATIVE_INFINITY
as result.Example:
BigDecimalMath.isDoubleValue(new BigDecimal("1E309"))
returnsfalse
, becausenew BigDecimal("1E309").doubleValue()
returnsInfinity
.Note: This method does not check for possible loss of precision.
For example
BigDecimalMath.isDoubleValue(new BigDecimal("1.23400000000000000000000000000000001"))
will returntrue
, becausenew BigDecimal("1.23400000000000000000000000000000001").doubleValue()
returns a valid double value, although it loses precision and returns1.234
.BigDecimalMath.isDoubleValue(new BigDecimal("1E-325"))
will returntrue
although this value is smaller thanDouble.MIN_VALUE
(and therefore outside the range of values that can be represented asdouble
) becausenew BigDecimal("1E-325").doubleValue()
returns0
which is a legal value with loss of precision.- Parameters:
value
- theBigDecimal
to check- Returns:
true
if the value can be represented asdouble
value
-
mantissa
Returns the mantissa of the specifiedBigDecimal
written as mantissa * 10exponent.The mantissa is defined as having exactly 1 digit before the decimal point.
- Parameters:
value
- theBigDecimal
- Returns:
- the mantissa
- See Also:
-
exponent
Returns the exponent of the specifiedBigDecimal
written as mantissa * 10exponent.The mantissa is defined as having exactly 1 digit before the decimal point.
- Parameters:
value
- theBigDecimal
- Returns:
- the exponent
- See Also:
-
significantDigits
Returns the number of significant digits of the specifiedBigDecimal
.The result contains the number of all digits before the decimal point and all digits after the decimal point excluding trailing zeroes.
Examples:
significantDigits(new BigDecimal("12300.00"))
returns 5significantDigits(new BigDecimal("1.23000"))
returns 3significantDigits(new BigDecimal("0.00012300"))
returns 3significantDigits(new BigDecimal("12300.4500"))
returns 7
- Parameters:
value
- theBigDecimal
- Returns:
- the number of significant digits
- See Also:
-
integralPart
Returns the integral part of the specifiedBigDecimal
(left of the decimal point).- Parameters:
value
- theBigDecimal
- Returns:
- the integral part
- See Also:
-
fractionalPart
Returns the fractional part of the specifiedBigDecimal
(right of the decimal point).- Parameters:
value
- theBigDecimal
- Returns:
- the fractional part
- See Also:
-
round
Rounds the specifiedBigDecimal
to the precision of the specifiedMathContext
.This method calls
BigDecimal.round(MathContext)
.- Parameters:
value
- theBigDecimal
to roundmathContext
- theMathContext
used for the result- Returns:
- the rounded
BigDecimal
value - See Also:
-
roundWithTrailingZeroes
Rounds the specifiedBigDecimal
to the precision of the specifiedMathContext
including trailing zeroes.This method is similar to
BigDecimal.round(MathContext)
but does not remove the trailing zeroes.Example:
MathContext mc = new MathContext(5); System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("1.234567"), mc)); // 1.2346 System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("123.4567"), mc)); // 123.46 System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("0.001234567"), mc)); // 0.0012346 System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("1.23"), mc)); // 1.2300 System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("1.230000"), mc)); // 1.2300 System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("0.00123"), mc)); // 0.0012300 System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("0"), mc)); // 0.0000 System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("0.00000000"), mc)); // 0.0000
- Parameters:
value
- theBigDecimal
to roundmathContext
- theMathContext
used for the result- Returns:
- the rounded
BigDecimal
value including trailing zeroes - See Also:
-
reciprocal
Calculates the reciprocal of the specifiedBigDecimal
.- Parameters:
x
- theBigDecimal
mathContext
- theMathContext
used for the result- Returns:
- the reciprocal
BigDecimal
- Throws:
ArithmeticException
- if x = 0ArithmeticException
- if the result is inexact but the rounding mode isUNNECESSARY
ormc.precision == 0
and the quotient has a non-terminating decimal expansion.
-
factorial
Calculates the factorial of the specified integer argument.factorial = 1 * 2 * 3 * ... n
- Parameters:
n
- theBigDecimal
- Returns:
- the factorial
BigDecimal
- Throws:
ArithmeticException
- if x < 0
-
factorialLoop
-
factorialRecursion
-
factorial
Calculates the factorial of the specifiedBigDecimal
.This implementation uses Spouge's approximation to calculate the factorial for non-integer values.
This involves calculating a series of constants that depend on the desired precision. Since this constant calculation is quite expensive (especially for higher precisions), the constants for a specific precision will be cached and subsequent calls to this method with the same precision will be much faster.
It is therefore recommended to do one call to this method with the standard precision of your application during the startup phase and to avoid calling it with many different precisions.
See: Wikipedia: Factorial - Extension of factorial to non-integer values of argument
- Parameters:
x
- theBigDecimal
mathContext
- theMathContext
used for the result- Returns:
- the factorial
BigDecimal
- Throws:
ArithmeticException
- if x is a negative integer value (-1, -2, -3, ...)UnsupportedOperationException
- if x is a non-integer value and theMathContext
has unlimited precision- See Also:
-
getSpougeFactorialConstants
-
gamma
Calculates the gamma function of the specifiedBigDecimal
.This implementation uses
factorial(BigDecimal, MathContext)
internally, therefore the performance implications described there apply also for this method.- Parameters:
x
- theBigDecimal
mathContext
- theMathContext
used for the result- Returns:
- the gamma
BigDecimal
- Throws:
ArithmeticException
- if x-1 is a negative integer value (-1, -2, -3, ...)UnsupportedOperationException
- if x is a non-integer value and theMathContext
has unlimited precision- See Also:
-
bernoulli
Calculates the Bernoulli number for the specified index.This function calculates the first Bernoulli numbers and therefore
bernoulli(1)
returns -0.5Note that
bernoulli(x)
for all odd x > 1 returns 0- Parameters:
n
- the index of the Bernoulli number to be calculated (starting at 0)mathContext
- theMathContext
used for the result- Returns:
- the Bernoulli number for the specified index
- Throws:
ArithmeticException
- if x < 0ArithmeticException
- if the result is inexact but the rounding mode isUNNECESSARY
ormc.precision == 0
and the quotient has a non-terminating decimal expansion.
-
pow
CalculatesBigDecimal
x to the power ofBigDecimal
y (xy).- Parameters:
x
- theBigDecimal
value to take to the powery
- theBigDecimal
value to serve as exponentmathContext
- theMathContext
used for the result- Returns:
- the calculated x to the power of y with the precision specified in the
mathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision- See Also:
-
pow
CalculatesBigDecimal
x to the power oflong
y (xy).The implementation tries to minimize the number of multiplications of
x
(using squares whenever possible).- Parameters:
x
- theBigDecimal
value to take to the powery
- thelong
value to serve as exponentmathContext
- theMathContext
used for the result- Returns:
- the calculated x to the power of y with the precision specified in the
mathContext
- Throws:
ArithmeticException
- if y is negative and the result is inexact but the rounding mode isUNNECESSARY
ormc.precision == 0
and the quotient has a non-terminating decimal expansion.ArithmeticException
- if the rounding mode isUNNECESSARY
and theBigDecimal
operation would require rounding.
-
powInteger
CalculatesBigDecimal
x to the power of the integer value y (xy).The value y MUST be an integer value.
- Parameters:
x
- theBigDecimal
value to take to the powerintegerY
- theBigDecimal
integer value to serve as exponentmathContext
- theMathContext
used for the result- Returns:
- the calculated x to the power of y with the precision specified in the
mathContext
- See Also:
-
sqrt
Calculates the square root ofBigDecimal
x.- Parameters:
x
- theBigDecimal
value to calculate the square rootmathContext
- theMathContext
used for the result- Returns:
- the calculated square root of x with the precision specified in the
mathContext
- Throws:
ArithmeticException
- if x < 0UnsupportedOperationException
- if theMathContext
has unlimited precision
-
root
Calculates the n'th root ofBigDecimal
x.- Parameters:
x
- theBigDecimal
value to calculate the n'th rootn
- theBigDecimal
defining the rootmathContext
- theMathContext
used for the result- Returns:
- the calculated n'th root of x with the precision specified in the
mathContext
- Throws:
ArithmeticException
- if n <= 0ArithmeticException
- if x < 0UnsupportedOperationException
- if theMathContext
has unlimited precision
-
rootUsingNewtonRaphson
private static BigDecimal rootUsingNewtonRaphson(BigDecimal x, BigDecimal n, BigDecimal initialResult, MathContext mathContext) -
log
Calculates the natural logarithm ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the natural logarithm formathContext
- theMathContext
used for the result- Returns:
- the calculated natural logarithm
BigDecimal
with the precision specified in themathContext
- Throws:
ArithmeticException
- if x <= 0UnsupportedOperationException
- if theMathContext
has unlimited precision
-
log2
Calculates the logarithm ofBigDecimal
x to the base 2.- Parameters:
x
- theBigDecimal
to calculate the logarithm base 2 formathContext
- theMathContext
used for the result- Returns:
- the calculated natural logarithm
BigDecimal
to the base 2 with the precision specified in themathContext
- Throws:
ArithmeticException
- if x <= 0UnsupportedOperationException
- if theMathContext
has unlimited precision
-
log10
Calculates the logarithm ofBigDecimal
x to the base 10.- Parameters:
x
- theBigDecimal
to calculate the logarithm base 10 formathContext
- theMathContext
used for the result- Returns:
- the calculated natural logarithm
BigDecimal
to the base 10 with the precision specified in themathContext
- Throws:
ArithmeticException
- if x <= 0UnsupportedOperationException
- if theMathContext
has unlimited precision
-
logUsingNewton
-
logUsingExponent
-
logUsingTwoThree
-
pi
Returns the number pi.See Wikipedia: Pi
- Parameters:
mathContext
- theMathContext
used for the result- Returns:
- the number pi with the precision specified in the
mathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
piChudnovski
-
e
Returns the number e.- Parameters:
mathContext
- theMathContext
used for the result- Returns:
- the number e with the precision specified in the
mathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
logTen
-
logTwo
-
logThree
-
exp
Calculates the natural exponent ofBigDecimal
x (ex).See: Wikipedia: Exponent
- Parameters:
x
- theBigDecimal
to calculate the exponent formathContext
- theMathContext
used for the result- Returns:
- the calculated exponent
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
expIntegralFractional
-
expTaylor
-
sin
Calculates the sine (sinus) ofBigDecimal
x.See: Wikipedia: Sine
- Parameters:
x
- theBigDecimal
to calculate the sine formathContext
- theMathContext
used for the result- Returns:
- the calculated sine
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
asin
Calculates the arc sine (inverted sine) ofBigDecimal
x.See: Wikipedia: Arcsine
- Parameters:
x
- theBigDecimal
to calculate the arc sine formathContext
- theMathContext
used for the result- Returns:
- the calculated arc sine
BigDecimal
with the precision specified in themathContext
- Throws:
ArithmeticException
- if x > 1 or x < -1UnsupportedOperationException
- if theMathContext
has unlimited precision
-
cos
Calculates the cosine (cosinus) ofBigDecimal
x.See: Wikipedia: Cosine
- Parameters:
x
- theBigDecimal
to calculate the cosine formathContext
- theMathContext
used for the result- Returns:
- the calculated cosine
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
acos
Calculates the arc cosine (inverted cosine) ofBigDecimal
x.See: Wikipedia: Arccosine
- Parameters:
x
- theBigDecimal
to calculate the arc cosine formathContext
- theMathContext
used for the result- Returns:
- the calculated arc sine
BigDecimal
with the precision specified in themathContext
- Throws:
ArithmeticException
- if x > 1 or x < -1UnsupportedOperationException
- if theMathContext
has unlimited precision
-
tan
Calculates the tangens ofBigDecimal
x.See: Wikipedia: Tangens
- Parameters:
x
- theBigDecimal
to calculate the tangens formathContext
- theMathContext
used for the result- Returns:
- the calculated tangens
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
atan
Calculates the arc tangens (inverted tangens) ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the arc tangens formathContext
- theMathContext
used for the result- Returns:
- the calculated arc tangens
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
atan2
Calculates the arc tangens (inverted tangens) ofBigDecimal
y / x in the range -pi to pi.This is useful to calculate the angle theta from the conversion of rectangular coordinates (
x
,y
) to polar coordinates (r, theta).See: Wikipedia: Atan2
- Parameters:
y
- theBigDecimal
x
- theBigDecimal
mathContext
- theMathContext
used for the result- Returns:
- the calculated arc tangens
BigDecimal
with the precision specified in themathContext
- Throws:
ArithmeticException
- if x = 0 and y = 0UnsupportedOperationException
- if theMathContext
has unlimited precision
-
cot
Calculates the cotangens ofBigDecimal
x.See: Wikipedia: Cotangens
- Parameters:
x
- theBigDecimal
to calculate the cotangens formathContext
- theMathContext
used for the result- Returns:
- the calculated cotanges
BigDecimal
with the precision specified in themathContext
- Throws:
ArithmeticException
- if x = 0UnsupportedOperationException
- if theMathContext
has unlimited precision
-
acot
Calculates the inverse cotangens (arc cotangens) ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the arc cotangens formathContext
- theMathContext
used for the result- Returns:
- the calculated arc cotangens
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
sinh
Calculates the hyperbolic sine ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the hyperbolic sine formathContext
- theMathContext
used for the result- Returns:
- the calculated hyperbolic sine
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
cosh
Calculates the hyperbolic cosine ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the hyperbolic cosine formathContext
- theMathContext
used for the result- Returns:
- the calculated hyperbolic cosine
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
tanh
Calculates the hyperbolic tangens ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the hyperbolic tangens formathContext
- theMathContext
used for the result- Returns:
- the calculated hyperbolic tangens
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
coth
Calculates the hyperbolic cotangens ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the hyperbolic cotangens formathContext
- theMathContext
used for the result- Returns:
- the calculated hyperbolic cotangens
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
asinh
Calculates the arc hyperbolic sine (inverse hyperbolic sine) ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the arc hyperbolic sine formathContext
- theMathContext
used for the result- Returns:
- the calculated arc hyperbolic sine
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
acosh
Calculates the arc hyperbolic cosine (inverse hyperbolic cosine) ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the arc hyperbolic cosine formathContext
- theMathContext
used for the result- Returns:
- the calculated arc hyperbolic cosine
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
atanh
Calculates the arc hyperbolic tangens (inverse hyperbolic tangens) ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the arc hyperbolic tangens formathContext
- theMathContext
used for the result- Returns:
- the calculated arc hyperbolic tangens
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
acoth
Calculates the arc hyperbolic cotangens (inverse hyperbolic cotangens) ofBigDecimal
x.- Parameters:
x
- theBigDecimal
to calculate the arc hyperbolic cotangens formathContext
- theMathContext
used for the result- Returns:
- the calculated arc hyperbolic cotangens
BigDecimal
with the precision specified in themathContext
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
toDegrees
Converts an angle measured in radians to an approximately equivalent angle measured in degrees. The conversion from radians to degrees is generally inexact, it uses the number PI with the precision specified in the mathContext.- Parameters:
x
- An angle in radians.mathContext
- theMathContext
used for the result- Returns:
- The angle in degrees.
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
toRadians
/** Converts an angle measured in degrees to an approximately equivalent angle measured in radians. The conversion from degrees to radians is generally inexact, it uses the number PI with the precision specified in the mathContext.- Parameters:
x
- An angle in degrees.mathContext
- theMathContext
used for the result- Returns:
- The angle in radians.
- Throws:
UnsupportedOperationException
- if theMathContext
has unlimited precision
-
checkMathContext
-