Class BigDecimalMath
BigDecimals.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BigDecimalprivate static BigDecimalprivate static final Objectprivate static final intprivate static BigDecimal[]private static BigDecimalprivate static final Objectprivate static BigDecimalprivate static final Objectprivate static BigDecimalprivate static final Objectprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static BigDecimalprivate static final Objectprivate static final BigDecimalprivate static final Map<Integer, List<BigDecimal>> private static final Objectprivate static final BigDecimalprivate static final BigDecimal -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalacos(BigDecimal x, MathContext mathContext) Calculates the arc cosine (inverted cosine) ofBigDecimalx.static BigDecimalacosh(BigDecimal x, MathContext mathContext) Calculates the arc hyperbolic cosine (inverse hyperbolic cosine) ofBigDecimalx.static BigDecimalacot(BigDecimal x, MathContext mathContext) Calculates the inverse cotangens (arc cotangens) ofBigDecimalx.static BigDecimalacoth(BigDecimal x, MathContext mathContext) Calculates the arc hyperbolic cotangens (inverse hyperbolic cotangens) ofBigDecimalx.private static intadjustScale(int scale, long exp) static BigDecimalasin(BigDecimal x, MathContext mathContext) Calculates the arc sine (inverted sine) ofBigDecimalx.static BigDecimalasinh(BigDecimal x, MathContext mathContext) Calculates the arc hyperbolic sine (inverse hyperbolic sine) ofBigDecimalx.static BigDecimalatan(BigDecimal x, MathContext mathContext) Calculates the arc tangens (inverted tangens) ofBigDecimalx.static BigDecimalatan2(BigDecimal y, BigDecimal x, MathContext mathContext) Calculates the arc tangens (inverted tangens) ofBigDecimaly / x in the range -pi to pi.static BigDecimalatanh(BigDecimal x, MathContext mathContext) Calculates the arc hyperbolic tangens (inverse hyperbolic tangens) ofBigDecimalx.static BigDecimalbernoulli(int n, MathContext mathContext) Calculates the Bernoulli number for the specified index.private static voidcheckMathContext(MathContext mathContext) static BigDecimalcos(BigDecimal x, MathContext mathContext) Calculates the cosine (cosinus) ofBigDecimalx.static BigDecimalcosh(BigDecimal x, MathContext mathContext) Calculates the hyperbolic cosine ofBigDecimalx.static BigDecimalcot(BigDecimal x, MathContext mathContext) Calculates the cotangens ofBigDecimalx.static BigDecimalcoth(BigDecimal x, MathContext mathContext) Calculates the hyperbolic cotangens ofBigDecimalx.static BigDecimale(MathContext mathContext) Returns the number e.static BigDecimalexp(BigDecimal x, MathContext mathContext) Calculates the natural exponent ofBigDecimalx (ex).private static BigDecimalexpIntegralFractional(BigDecimal x, MathContext mathContext) static intexponent(BigDecimal value) Returns the exponent of the specifiedBigDecimalwritten as mantissa * 10exponent.private static BigDecimalexpTaylor(BigDecimal x, MathContext mathContext) static BigDecimalfactorial(int n) Calculates the factorial of the specified integer argument.static BigDecimalfactorial(BigDecimal x, MathContext mathContext) Calculates the factorial of the specifiedBigDecimal.private static BigDecimalfactorialLoop(int n1, int n2) private static BigDecimalfactorialRecursion(int n1, int n2) static BigDecimalfractionalPart(BigDecimal value) Returns the fractional part of the specifiedBigDecimal(right of the decimal point).static BigDecimalgamma(BigDecimal x, MathContext mathContext) Calculates the gamma function of the specifiedBigDecimal.(package private) static List<BigDecimal> getSpougeFactorialConstants(int a) static BigDecimalintegralPart(BigDecimal value) Returns the integral part of the specifiedBigDecimal(left of the decimal point).static booleanisDoubleValue(BigDecimal value) Returns whether the specifiedBigDecimalvalue can be represented asdouble.static booleanisIntValue(BigDecimal value) Returns whether the specifiedBigDecimalvalue can be represented asint.static booleanisLongValue(BigDecimal value) Returns whether the specifiedBigDecimalvalue can be represented aslong.static BigDecimallog(BigDecimal x, MathContext mathContext) Calculates the natural logarithm ofBigDecimalx.static BigDecimallog10(BigDecimal x, MathContext mathContext) Calculates the logarithm ofBigDecimalx to the base 10.static BigDecimallog2(BigDecimal x, MathContext mathContext) Calculates the logarithm ofBigDecimalx to the base 2.private static BigDecimallogTen(MathContext mathContext) private static BigDecimallogThree(MathContext mathContext) private static BigDecimallogTwo(MathContext mathContext) private static BigDecimallogUsingExponent(BigDecimal x, MathContext mathContext) private static BigDecimallogUsingNewton(BigDecimal x, MathContext mathContext) private static BigDecimallogUsingTwoThree(BigDecimal x, MathContext mathContext) static BigDecimalmantissa(BigDecimal value) Returns the mantissa of the specifiedBigDecimalwritten as mantissa * 10exponent.static BigDecimalpi(MathContext mathContext) Returns the number pi.private static BigDecimalpiChudnovski(MathContext mathContext) static BigDecimalpow(BigDecimal x, long y, MathContext mathContext) CalculatesBigDecimalx to the power oflongy (xy).static BigDecimalpow(BigDecimal x, BigDecimal y, MathContext mathContext) CalculatesBigDecimalx to the power ofBigDecimaly (xy).private static BigDecimalpowInteger(BigDecimal x, BigDecimal integerY, MathContext mathContext) CalculatesBigDecimalx to the power of the integer value y (xy).static BigDecimalreciprocal(BigDecimal x, MathContext mathContext) Calculates the reciprocal of the specifiedBigDecimal.static BigDecimalroot(BigDecimal x, BigDecimal n, MathContext mathContext) Calculates the n'th root ofBigDecimalx.private static BigDecimalrootUsingNewtonRaphson(BigDecimal x, BigDecimal n, BigDecimal initialResult, MathContext mathContext) static BigDecimalround(BigDecimal value, MathContext mathContext) Rounds the specifiedBigDecimalto the precision of the specifiedMathContext.static BigDecimalroundWithTrailingZeroes(BigDecimal value, MathContext mathContext) Rounds the specifiedBigDecimalto the precision of the specifiedMathContextincluding trailing zeroes.static intsignificantDigits(BigDecimal value) Returns the number of significant digits of the specifiedBigDecimal.static BigDecimalsin(BigDecimal x, MathContext mathContext) Calculates the sine (sinus) ofBigDecimalx.static BigDecimalsinh(BigDecimal x, MathContext mathContext) Calculates the hyperbolic sine ofBigDecimalx.static BigDecimalsqrt(BigDecimal x, MathContext mathContext) Calculates the square root ofBigDecimalx.static BigDecimaltan(BigDecimal x, MathContext mathContext) Calculates the tangens ofBigDecimalx.static BigDecimaltanh(BigDecimal x, MathContext mathContext) Calculates the hyperbolic tangens ofBigDecimalx.static BigDecimaltoBigDecimal(String string) Creates aBigDecimalfrom the specifiedStringrepresentation.static BigDecimaltoBigDecimal(String string, MathContext mathContext) Creates aBigDecimalfrom the specifiedStringrepresentation.(package private) static BigDecimaltoBigDecimal(String string, MathContext mathContext, int splitLength) private static BigDecimaltoBigDecimalRecursive(char[] chars, int offset, int length, int scale, int splitLength) static BigDecimaltoDegrees(BigDecimal x, MathContext mathContext) Converts an angle measured in radians to an approximately equivalent angle measured in degrees.static BigDecimaltoRadians(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 aBigDecimalfrom the specifiedStringrepresentation.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- ifstringis not a valid representation of aBigDecimal- See Also:
-
toBigDecimal
Creates aBigDecimalfrom the specifiedStringrepresentation.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- theMathContextused for the result- Returns:
- the created
BigDecimal - Throws:
NumberFormatException- ifstringis not a valid representation of aBigDecimalArithmeticException- 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 specifiedBigDecimalvalue can be represented asint.If this returns
trueyou can callBigDecimal.intValueExact()without fear of anArithmeticException.- Parameters:
value- theBigDecimalto check- Returns:
trueif the value can be represented asintvalue
-
isLongValue
Returns whether the specifiedBigDecimalvalue can be represented aslong.If this returns
trueyou can callBigDecimal.longValueExact()without fear of anArithmeticException.- Parameters:
value- theBigDecimalto check- Returns:
trueif the value can be represented aslongvalue
-
isDoubleValue
Returns whether the specifiedBigDecimalvalue can be represented asdouble.If this returns
trueyou can callBigDecimal.doubleValue()without fear of gettingDouble.POSITIVE_INFINITYorDouble.NEGATIVE_INFINITYas 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 returntruealthough this value is smaller thanDouble.MIN_VALUE(and therefore outside the range of values that can be represented asdouble) becausenew BigDecimal("1E-325").doubleValue()returns0which is a legal value with loss of precision.- Parameters:
value- theBigDecimalto check- Returns:
trueif the value can be represented asdoublevalue
-
mantissa
Returns the mantissa of the specifiedBigDecimalwritten 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 specifiedBigDecimalwritten 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 specifiedBigDecimalto the precision of the specifiedMathContext.This method calls
BigDecimal.round(MathContext).- Parameters:
value- theBigDecimalto roundmathContext- theMathContextused for the result- Returns:
- the rounded
BigDecimalvalue - See Also:
-
roundWithTrailingZeroes
Rounds the specifiedBigDecimalto the precision of the specifiedMathContextincluding 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- theBigDecimalto roundmathContext- theMathContextused for the result- Returns:
- the rounded
BigDecimalvalue including trailing zeroes - See Also:
-
reciprocal
Calculates the reciprocal of the specifiedBigDecimal.- Parameters:
x- theBigDecimalmathContext- theMathContextused for the result- Returns:
- the reciprocal
BigDecimal - Throws:
ArithmeticException- if x = 0ArithmeticException- if the result is inexact but the rounding mode isUNNECESSARYormc.precision == 0and 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- theBigDecimalmathContext- theMathContextused 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 theMathContexthas 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- theBigDecimalmathContext- theMathContextused 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 theMathContexthas 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- theMathContextused 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 isUNNECESSARYormc.precision == 0and the quotient has a non-terminating decimal expansion.
-
pow
CalculatesBigDecimalx to the power ofBigDecimaly (xy).- Parameters:
x- theBigDecimalvalue to take to the powery- theBigDecimalvalue to serve as exponentmathContext- theMathContextused for the result- Returns:
- the calculated x to the power of y with the precision specified in the
mathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision- See Also:
-
pow
CalculatesBigDecimalx to the power oflongy (xy).The implementation tries to minimize the number of multiplications of
x(using squares whenever possible).- Parameters:
x- theBigDecimalvalue to take to the powery- thelongvalue to serve as exponentmathContext- theMathContextused 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 isUNNECESSARYormc.precision == 0and the quotient has a non-terminating decimal expansion.ArithmeticException- if the rounding mode isUNNECESSARYand theBigDecimaloperation would require rounding.
-
powInteger
CalculatesBigDecimalx to the power of the integer value y (xy).The value y MUST be an integer value.
- Parameters:
x- theBigDecimalvalue to take to the powerintegerY- theBigDecimalinteger value to serve as exponentmathContext- theMathContextused 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 ofBigDecimalx.- Parameters:
x- theBigDecimalvalue to calculate the square rootmathContext- theMathContextused for the result- Returns:
- the calculated square root of x with the precision specified in the
mathContext - Throws:
ArithmeticException- if x < 0UnsupportedOperationException- if theMathContexthas unlimited precision
-
root
Calculates the n'th root ofBigDecimalx.- Parameters:
x- theBigDecimalvalue to calculate the n'th rootn- theBigDecimaldefining the rootmathContext- theMathContextused 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 theMathContexthas unlimited precision
-
rootUsingNewtonRaphson
private static BigDecimal rootUsingNewtonRaphson(BigDecimal x, BigDecimal n, BigDecimal initialResult, MathContext mathContext) -
log
Calculates the natural logarithm ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the natural logarithm formathContext- theMathContextused for the result- Returns:
- the calculated natural logarithm
BigDecimalwith the precision specified in themathContext - Throws:
ArithmeticException- if x <= 0UnsupportedOperationException- if theMathContexthas unlimited precision
-
log2
Calculates the logarithm ofBigDecimalx to the base 2.- Parameters:
x- theBigDecimalto calculate the logarithm base 2 formathContext- theMathContextused for the result- Returns:
- the calculated natural logarithm
BigDecimalto the base 2 with the precision specified in themathContext - Throws:
ArithmeticException- if x <= 0UnsupportedOperationException- if theMathContexthas unlimited precision
-
log10
Calculates the logarithm ofBigDecimalx to the base 10.- Parameters:
x- theBigDecimalto calculate the logarithm base 10 formathContext- theMathContextused for the result- Returns:
- the calculated natural logarithm
BigDecimalto the base 10 with the precision specified in themathContext - Throws:
ArithmeticException- if x <= 0UnsupportedOperationException- if theMathContexthas unlimited precision
-
logUsingNewton
-
logUsingExponent
-
logUsingTwoThree
-
pi
Returns the number pi.See Wikipedia: Pi
- Parameters:
mathContext- theMathContextused for the result- Returns:
- the number pi with the precision specified in the
mathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
piChudnovski
-
e
Returns the number e.- Parameters:
mathContext- theMathContextused for the result- Returns:
- the number e with the precision specified in the
mathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
logTen
-
logTwo
-
logThree
-
exp
Calculates the natural exponent ofBigDecimalx (ex).See: Wikipedia: Exponent
- Parameters:
x- theBigDecimalto calculate the exponent formathContext- theMathContextused for the result- Returns:
- the calculated exponent
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
expIntegralFractional
-
expTaylor
-
sin
Calculates the sine (sinus) ofBigDecimalx.See: Wikipedia: Sine
- Parameters:
x- theBigDecimalto calculate the sine formathContext- theMathContextused for the result- Returns:
- the calculated sine
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
asin
Calculates the arc sine (inverted sine) ofBigDecimalx.See: Wikipedia: Arcsine
- Parameters:
x- theBigDecimalto calculate the arc sine formathContext- theMathContextused for the result- Returns:
- the calculated arc sine
BigDecimalwith the precision specified in themathContext - Throws:
ArithmeticException- if x > 1 or x < -1UnsupportedOperationException- if theMathContexthas unlimited precision
-
cos
Calculates the cosine (cosinus) ofBigDecimalx.See: Wikipedia: Cosine
- Parameters:
x- theBigDecimalto calculate the cosine formathContext- theMathContextused for the result- Returns:
- the calculated cosine
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
acos
Calculates the arc cosine (inverted cosine) ofBigDecimalx.See: Wikipedia: Arccosine
- Parameters:
x- theBigDecimalto calculate the arc cosine formathContext- theMathContextused for the result- Returns:
- the calculated arc sine
BigDecimalwith the precision specified in themathContext - Throws:
ArithmeticException- if x > 1 or x < -1UnsupportedOperationException- if theMathContexthas unlimited precision
-
tan
Calculates the tangens ofBigDecimalx.See: Wikipedia: Tangens
- Parameters:
x- theBigDecimalto calculate the tangens formathContext- theMathContextused for the result- Returns:
- the calculated tangens
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
atan
Calculates the arc tangens (inverted tangens) ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the arc tangens formathContext- theMathContextused for the result- Returns:
- the calculated arc tangens
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
atan2
Calculates the arc tangens (inverted tangens) ofBigDecimaly / 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- theBigDecimalx- theBigDecimalmathContext- theMathContextused for the result- Returns:
- the calculated arc tangens
BigDecimalwith the precision specified in themathContext - Throws:
ArithmeticException- if x = 0 and y = 0UnsupportedOperationException- if theMathContexthas unlimited precision
-
cot
Calculates the cotangens ofBigDecimalx.See: Wikipedia: Cotangens
- Parameters:
x- theBigDecimalto calculate the cotangens formathContext- theMathContextused for the result- Returns:
- the calculated cotanges
BigDecimalwith the precision specified in themathContext - Throws:
ArithmeticException- if x = 0UnsupportedOperationException- if theMathContexthas unlimited precision
-
acot
Calculates the inverse cotangens (arc cotangens) ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the arc cotangens formathContext- theMathContextused for the result- Returns:
- the calculated arc cotangens
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
sinh
Calculates the hyperbolic sine ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the hyperbolic sine formathContext- theMathContextused for the result- Returns:
- the calculated hyperbolic sine
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
cosh
Calculates the hyperbolic cosine ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the hyperbolic cosine formathContext- theMathContextused for the result- Returns:
- the calculated hyperbolic cosine
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
tanh
Calculates the hyperbolic tangens ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the hyperbolic tangens formathContext- theMathContextused for the result- Returns:
- the calculated hyperbolic tangens
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
coth
Calculates the hyperbolic cotangens ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the hyperbolic cotangens formathContext- theMathContextused for the result- Returns:
- the calculated hyperbolic cotangens
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
asinh
Calculates the arc hyperbolic sine (inverse hyperbolic sine) ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the arc hyperbolic sine formathContext- theMathContextused for the result- Returns:
- the calculated arc hyperbolic sine
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
acosh
Calculates the arc hyperbolic cosine (inverse hyperbolic cosine) ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the arc hyperbolic cosine formathContext- theMathContextused for the result- Returns:
- the calculated arc hyperbolic cosine
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
atanh
Calculates the arc hyperbolic tangens (inverse hyperbolic tangens) ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the arc hyperbolic tangens formathContext- theMathContextused for the result- Returns:
- the calculated arc hyperbolic tangens
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
acoth
Calculates the arc hyperbolic cotangens (inverse hyperbolic cotangens) ofBigDecimalx.- Parameters:
x- theBigDecimalto calculate the arc hyperbolic cotangens formathContext- theMathContextused for the result- Returns:
- the calculated arc hyperbolic cotangens
BigDecimalwith the precision specified in themathContext - Throws:
UnsupportedOperationException- if theMathContexthas 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- theMathContextused for the result- Returns:
- The angle in degrees.
- Throws:
UnsupportedOperationException- if theMathContexthas 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- theMathContextused for the result- Returns:
- The angle in radians.
- Throws:
UnsupportedOperationException- if theMathContexthas unlimited precision
-
checkMathContext
-