Class DefaultBigDecimalMath
- java.lang.Object
-
- ch.obermuhlner.math.big.DefaultBigDecimalMath
-
public class DefaultBigDecimalMath extends java.lang.ObjectA wrapper aroundBigDecimalMaththat passes a currentMathContextto the functions that need aMathContextargument.The initial default
MathContextis equivalent toMathContext.DECIMAL128but this can be overridden by setting the following system properties:ch.obermuhlner.math.big.default.precisionto a positive integer precision (default=34)ch.obermuhlner.math.big.default.roundingto aRoundingModename (default=HALF_UP)
It is also possible to programmatically set the default
MathContextusingsetDefaultMathContext(MathContext). It is recommended to set the desired precision in theMathContextvery early in the startup of the application and to not change it afterwards.Important: Avoid the pitfall of setting the precision temporarily using
setDefaultMathContext(MathContext)for a calculation. This can lead to race conditions and calculations with the wrong precision if other threads in your application do the same thing.To set a temporary
MathContextyou have to choice to use either:DefaultBigDecimalMath.createLocalMathContext()in a try-with-resources statementDefaultBigDecimalMath.withLocalMathContext()with a lambda function
DefaultBigDecimalMath.createLocalMathContext():System.out.println("Pi[default]: " + DefaultBigDecimalMath.pi()); try (DefaultBigDecimalMath.LocalMathContext context = DefaultBigDecimalMath.createLocalMathContext(5)) { System.out.println("Pi[5]: " + DefaultBigDecimalMath.pi()); try (DefaultBigDecimalMath.LocalMathContext context2 = DefaultBigDecimalMath.createLocalMathContext(10)) { System.out.println("Pi[10]: " + DefaultBigDecimalMath.pi()); } System.out.println("Pi[5]: " + DefaultBigDecimalMath.pi()); } System.out.println("Pi[default]: " + DefaultBigDecimalMath.pi());Example code usingDefaultBigDecimalMath.withLocalMathContext():System.out.println("Pi[default]: " + DefaultBigDecimalMath.pi()); DefaultBigDecimalMath.withPrecision(5, () -> { System.out.println("Pi[5]: " + DefaultBigDecimalMath.pi()); DefaultBigDecimalMath.withPrecision(10, () -> { System.out.println("Pi[10]: " + DefaultBigDecimalMath.pi()); }); System.out.println("Pi[5]: " + DefaultBigDecimalMath.pi()); }); System.out.println("Pi[default]: " + DefaultBigDecimalMath.pi());Both snippets with give the following ouput:Pi[default]: 3.141592653589793238462643383279503 Pi[5]: 3.1416 Pi[10]: 3.141592654 Pi[5]: 3.1416 Pi[default]: 3.141592653589793238462643383279503
The temporary
MathContextare stored inThreadLocalvariables and will therefore not conflict with each other when used in multi-threaded use case.Important: Due to the
ThreadLocalvariables the localMathContextwill not be available in other threads. This includes streams usingparallel(), thread pools and manually started threads. If you need temporaryMathContextfor calculations then you must set the localMathContextinside every separate thread.try (DefaultBigDecimalMath.LocalMathContext context = DefaultBigDecimalMath.createLocalMathContext(5)) { BigDecimalStream.range(0.0, 1.0, 0.01, DefaultBigDecimalMath.currentMathContext()) .map(b -> DefaultBigDecimalMath.cos(b)) .map(b -> "sequential " + Thread.currentThread().getName() + " [5]: " + b) .forEach(System.out::println); BigDecimalStream.range(0.0, 1.0, 0.01, DefaultBigDecimalMath.currentMathContext()) .parallel() .map(b -> { try (DefaultBigDecimalMath.LocalMathContext context2 = DefaultBigDecimalMath.createLocalMathContext(5)) { return DefaultBigDecimalMath.cos(b); } }) .map(b -> "parallel " + Thread.currentThread().getName() + " [5]: " + b) .forEach(System.out::println); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultBigDecimalMath.LocalMathContextThe local context used to push and pop aMathContexton the stack.
-
Field Summary
Fields Modifier and Type Field Description private static java.math.MathContextdefaultMathContextprivate static java.lang.ThreadLocal<java.util.Deque<java.math.MathContext>>mathContextStack
-
Constructor Summary
Constructors Constructor Description DefaultBigDecimalMath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.math.BigDecimalacos(java.math.BigDecimal x)Calculates the arc cosine (inverted cosine) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalacosh(java.math.BigDecimal x)Calculates the arc hyperbolic cosine (inverse hyperbolic cosine) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalacot(java.math.BigDecimal x)Calculates the inverse cotangens (arc cotangens) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalacoth(java.math.BigDecimal x)Calculates the arc hyperbolic cotangens (inverse hyperbolic cotangens) ofBigDecimalx using the currentMathContext.static java.math.BigDecimaladd(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx + yusing the currentMathContext.static java.math.BigDecimalasin(java.math.BigDecimal x)Calculates the arc sine (inverted sine) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalasinh(java.math.BigDecimal x)Calculates the arc hyperbolic sine (inverse hyperbolic sine) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalatan(java.math.BigDecimal x)Calculates the arc tangens (inverted tangens) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalatan2(java.math.BigDecimal y, java.math.BigDecimal x)Calculates the arc tangens (inverted tangens) ofBigDecimaly / x in the range -pi to pi using the currentMathContext.static java.math.BigDecimalatanh(java.math.BigDecimal x)Calculates the arc hyperbolic tangens (inverse hyperbolic tangens) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalbernoulli(int n)Calculates the Bernoulli number for the specified index using the currentMathContext.static java.math.BigDecimalcos(java.math.BigDecimal x)Calculates the cosine (cosinus) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalcosh(java.math.BigDecimal x)Calculates the hyperbolic cosine ofBigDecimalx using the currentMathContext.static java.math.BigDecimalcot(java.math.BigDecimal x)Calculates the cotangens ofBigDecimalx using the currentMathContext.static java.math.BigDecimalcoth(java.math.BigDecimal x)Calculates the hyperbolic cotangens ofBigDecimalx using the currentMathContext.private static java.math.MathContextcreateDefaultMathContext()static DefaultBigDecimalMath.LocalMathContextcreateLocalMathContext(int precision)Executes the givenRunnableusing the specified precision.static DefaultBigDecimalMath.LocalMathContextcreateLocalMathContext(int precision, java.math.RoundingMode roundingMode)Executes the givenRunnableusing the specified precision andRoundingMode.static DefaultBigDecimalMath.LocalMathContextcreateLocalMathContext(java.math.MathContext mathContext)Executes the givenRunnableusing the specifiedMathContext.static java.math.MathContextcurrentMathContext()Returns the currentMathContextused for all mathematical functions in this class.static java.math.BigDecimaldivide(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx / yusing the currentMathContext.static java.math.BigDecimale()Returns the number e using the currentMathContext.static java.math.BigDecimalexp(java.math.BigDecimal x)Calculates the natural exponent ofBigDecimalx (ex) using the currentMathContext.static java.math.BigDecimalfactorial(java.math.BigDecimal x)Calculates the factorial of the specifiedBigDecimalusing the currentMathContext.static java.math.BigDecimalgamma(java.math.BigDecimal x)Calculates the gamma function of the specifiedBigDecimalusing the currentMathContext.static java.math.MathContextgetDefaultMathContext()Returns the defaultMathContextused for all mathematical functions in this class.private static intgetIntSystemProperty(java.lang.String propertyKey, int defaultValue)private static java.math.RoundingModegetRoundingModeSystemProperty(java.lang.String propertyKey, java.math.RoundingMode defaultValue)static java.math.BigDecimallog(java.math.BigDecimal x)Calculates the natural logarithm ofBigDecimalx using the currentMathContext.static java.math.BigDecimallog10(java.math.BigDecimal x)Calculates the logarithm ofBigDecimalx to the base 10 using the currentMathContext.static java.math.BigDecimallog2(java.math.BigDecimal x)Calculates the logarithm ofBigDecimalx to the base 2 using the currentMathContext.static java.math.BigDecimalmultiply(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx * yusing the currentMathContext.static java.math.BigDecimalpi()Returns the number pi using the currentMathContext.private static java.math.MathContextpopMathContext()static java.math.BigDecimalpow(java.math.BigDecimal x, long y)CalculatesBigDecimalx to the power oflongy (xy) using the currentMathContext.static java.math.BigDecimalpow(java.math.BigDecimal x, java.math.BigDecimal y)CalculatesBigDecimalx to the power ofBigDecimaly (xy) using the currentMathContext.private static <T> TpropertyException(java.lang.String propertyKey, java.lang.String propertyValue, T defaultValue)private static voidpushMathContext(java.math.MathContext mathContext)static java.math.BigDecimalreciprocal(java.math.BigDecimal x)Calculates the reciprocal of the specifiedBigDecimalusing the currentMathContext.static java.math.BigDecimalremainder(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx % yusing the currentMathContext.static java.math.BigDecimalroot(java.math.BigDecimal x, java.math.BigDecimal n)Calculates the n'th root ofBigDecimalx using the currentMathContext.static java.math.BigDecimalround(java.math.BigDecimal value)Rounds the specifiedBigDecimalto the precision of the currentMathContext.static java.math.BigDecimalroundWithTrailingZeroes(java.math.BigDecimal value)Rounds the specifiedBigDecimalto the precision of the currentMathContextincluding trailing zeroes.static voidsetDefaultMathContext(java.math.MathContext defaultMathContext)Sets the defaultMathContextused if no otherMathContextis defined usingwithLocalMathContext(MathContext, Runnable).static java.math.BigDecimalsin(java.math.BigDecimal x)Calculates the sine (sinus) ofBigDecimalx using the currentMathContext.static java.math.BigDecimalsinh(java.math.BigDecimal x)Calculates the hyperbolic sine ofBigDecimalx using the currentMathContext.static java.math.BigDecimalsqrt(java.math.BigDecimal x)Calculates the square root ofBigDecimalx using the currentMathContext.static java.math.BigDecimalsubtract(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx - yusing the currentMathContext.static java.math.BigDecimaltan(java.math.BigDecimal x)Calculates the tangens ofBigDecimalx using the currentMathContext.static java.math.BigDecimaltanh(java.math.BigDecimal x)Calculates the hyperbolic tangens ofBigDecimalx using the currentMathContext.static voidwithLocalMathContext(int precision, java.lang.Runnable runnable)Executes the givenRunnableusing the specified precision.static voidwithLocalMathContext(int precision, java.math.RoundingMode roundingMode, java.lang.Runnable runnable)Executes the givenRunnableusing the specified precision andRoundingMode.static voidwithLocalMathContext(java.math.MathContext mathContext, java.lang.Runnable runnable)Executes the givenRunnableusing the specifiedMathContext.
-
-
-
Method Detail
-
createDefaultMathContext
private static java.math.MathContext createDefaultMathContext()
-
pushMathContext
private static void pushMathContext(java.math.MathContext mathContext)
-
popMathContext
private static java.math.MathContext popMathContext()
-
getIntSystemProperty
private static int getIntSystemProperty(java.lang.String propertyKey, int defaultValue)
-
getRoundingModeSystemProperty
private static java.math.RoundingMode getRoundingModeSystemProperty(java.lang.String propertyKey, java.math.RoundingMode defaultValue)
-
propertyException
private static <T> T propertyException(java.lang.String propertyKey, java.lang.String propertyValue, T defaultValue)
-
setDefaultMathContext
public static void setDefaultMathContext(java.math.MathContext defaultMathContext)
Sets the defaultMathContextused if no otherMathContextis defined usingwithLocalMathContext(MathContext, Runnable).- Parameters:
defaultMathContext- the defaultMathContext- See Also:
currentMathContext(),withLocalMathContext(int, Runnable),withLocalMathContext(int, RoundingMode, Runnable),withLocalMathContext(MathContext, Runnable)
-
getDefaultMathContext
public static java.math.MathContext getDefaultMathContext()
Returns the defaultMathContextused for all mathematical functions in this class.- Returns:
- the default
MathContext
-
withLocalMathContext
public static void withLocalMathContext(int precision, java.lang.Runnable runnable)Executes the givenRunnableusing the specified precision.- Parameters:
precision- the precision to use for calculations in therunnablerunnable- theRunnableto execute
-
withLocalMathContext
public static void withLocalMathContext(int precision, java.math.RoundingMode roundingMode, java.lang.Runnable runnable)Executes the givenRunnableusing the specified precision andRoundingMode.- Parameters:
precision- the precision to use for calculations in therunnableroundingMode- theRoundingModeto use for calculations in therunnablerunnable- theRunnableto execute
-
withLocalMathContext
public static void withLocalMathContext(java.math.MathContext mathContext, java.lang.Runnable runnable)Executes the givenRunnableusing the specifiedMathContext.- Parameters:
mathContext- theMathContextto use for calculations in therunnablerunnable- theRunnableto execute
-
createLocalMathContext
public static DefaultBigDecimalMath.LocalMathContext createLocalMathContext(int precision)
Executes the givenRunnableusing the specified precision.- Parameters:
precision- the precision to use for calculations- Returns:
- the created
DefaultBigDecimalMath.LocalMathContextto be used in a try-with-resources statement
-
createLocalMathContext
public static DefaultBigDecimalMath.LocalMathContext createLocalMathContext(int precision, java.math.RoundingMode roundingMode)
Executes the givenRunnableusing the specified precision andRoundingMode.- Parameters:
precision- the precision to use for calculationsroundingMode- theRoundingModeto use for calculations in therunnable- Returns:
- the created
DefaultBigDecimalMath.LocalMathContextto be used in a try-with-resources statement
-
createLocalMathContext
public static DefaultBigDecimalMath.LocalMathContext createLocalMathContext(java.math.MathContext mathContext)
Executes the givenRunnableusing the specifiedMathContext.- Parameters:
mathContext- theMathContextto use for calculations- Returns:
- the created
DefaultBigDecimalMath.LocalMathContextto be used in a try-with-resources statement
-
currentMathContext
public static java.math.MathContext currentMathContext()
Returns the currentMathContextused for all mathematical functions in this class.The current
MathContextis the lastMathContextspecified usingwithLocalMathContext(MathContext, Runnable)or the defaultMathContextif none was specified.- Returns:
- the current
MathContext - See Also:
currentMathContext(),withLocalMathContext(int, Runnable),withLocalMathContext(int, RoundingMode, Runnable),withLocalMathContext(MathContext, Runnable)
-
round
public static java.math.BigDecimal round(java.math.BigDecimal value)
Rounds the specifiedBigDecimalto the precision of the currentMathContext.- Parameters:
value- theBigDecimalto round- Returns:
- the rounded
BigDecimalvalue - See Also:
currentMathContext(),BigDecimalMath.round(BigDecimal, MathContext)
-
roundWithTrailingZeroes
public static java.math.BigDecimal roundWithTrailingZeroes(java.math.BigDecimal value)
Rounds the specifiedBigDecimalto the precision of the currentMathContextincluding trailing zeroes.- Parameters:
value- theBigDecimalto round- Returns:
- the rounded
BigDecimalvalue including trailing zeroes - See Also:
currentMathContext(),BigDecimalMath.roundWithTrailingZeroes(BigDecimal, MathContext)
-
add
public static java.math.BigDecimal add(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx + yusing the currentMathContext.- Parameters:
x- the x valuey- the y value to add- Returns:
- the resulting
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimal.add(BigDecimal, MathContext)
-
subtract
public static java.math.BigDecimal subtract(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx - yusing the currentMathContext.- Parameters:
x- the x valuey- the y value to subtract- Returns:
- the resulting
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimal.subtract(BigDecimal, MathContext)
-
multiply
public static java.math.BigDecimal multiply(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx * yusing the currentMathContext.- Parameters:
x- the x valuey- the y value to multiply- Returns:
- the resulting
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimal.multiply(BigDecimal, MathContext)
-
divide
public static java.math.BigDecimal divide(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx / yusing the currentMathContext.- Parameters:
x- the x valuey- the y value to divide- Returns:
- the resulting
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimal.divide(BigDecimal, MathContext)
-
remainder
public static java.math.BigDecimal remainder(java.math.BigDecimal x, java.math.BigDecimal y)Returns theBigDecimalthat isx % yusing the currentMathContext.- Parameters:
x- the x valuey- the y value to divide- Returns:
- the resulting
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimal.remainder(BigDecimal, MathContext)
-
reciprocal
public static java.math.BigDecimal reciprocal(java.math.BigDecimal x)
Calculates the reciprocal of the specifiedBigDecimalusing the currentMathContext.- Parameters:
x- theBigDecimal- Returns:
- the reciprocal
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.reciprocal(BigDecimal, MathContext)
-
factorial
public static java.math.BigDecimal factorial(java.math.BigDecimal x)
Calculates the factorial of the specifiedBigDecimalusing the currentMathContext.- Parameters:
x- theBigDecimal- Returns:
- the factorial
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.factorial(BigDecimal, MathContext)
-
gamma
public static java.math.BigDecimal gamma(java.math.BigDecimal x)
Calculates the gamma function of the specifiedBigDecimalusing the currentMathContext.- Parameters:
x- theBigDecimal- Returns:
- the gamma
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.gamma(BigDecimal, MathContext)
-
bernoulli
public static java.math.BigDecimal bernoulli(int n)
Calculates the Bernoulli number for the specified index using the currentMathContext.- Parameters:
n- the index of the Bernoulli number to be calculated (starting at 0)- Returns:
- the Bernoulli number for the specified index with the precision specified in the current
MathContext - See Also:
currentMathContext(),BigDecimalMath.bernoulli(int, MathContext)
-
pow
public static java.math.BigDecimal pow(java.math.BigDecimal x, java.math.BigDecimal y)CalculatesBigDecimalx to the power ofBigDecimaly (xy) using the currentMathContext.- Parameters:
x- theBigDecimalvalue to take to the powery- theBigDecimalvalue to serve as exponent- Returns:
- the calculated x to the power of y with the precision specified in the current
MathContext - See Also:
currentMathContext(),BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
pow
public static java.math.BigDecimal pow(java.math.BigDecimal x, long y)CalculatesBigDecimalx to the power oflongy (xy) using the currentMathContext.- Parameters:
x- theBigDecimalvalue to take to the powery- thelongvalue to serve as exponent- Returns:
- the calculated x to the power of y with the precision specified in the current
MathContext - See Also:
currentMathContext(),BigDecimalMath.pow(BigDecimal, long, MathContext)
-
sqrt
public static java.math.BigDecimal sqrt(java.math.BigDecimal x)
Calculates the square root ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalvalue to calculate the square root- Returns:
- the calculated square root of x with the precision specified in the current
MathContext - See Also:
currentMathContext(),BigDecimalMath.sqrt(BigDecimal, MathContext)
-
root
public static java.math.BigDecimal root(java.math.BigDecimal x, java.math.BigDecimal n)Calculates the n'th root ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalvalue to calculate the n'th rootn- theBigDecimaldefining the root- Returns:
- the calculated n'th root of x with the precision specified in the current
MathContext - See Also:
currentMathContext(),BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)
-
log
public static java.math.BigDecimal log(java.math.BigDecimal x)
Calculates the natural logarithm ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the natural logarithm for- Returns:
- the calculated natural logarithm
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.log(BigDecimal, MathContext)
-
log2
public static java.math.BigDecimal log2(java.math.BigDecimal x)
Calculates the logarithm ofBigDecimalx to the base 2 using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the logarithm base 2 for- Returns:
- the calculated natural logarithm
BigDecimalto the base 2 with the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.log2(BigDecimal, MathContext)
-
log10
public static java.math.BigDecimal log10(java.math.BigDecimal x)
Calculates the logarithm ofBigDecimalx to the base 10 using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the logarithm base 10 for- Returns:
- the calculated natural logarithm
BigDecimalto the base 10 with the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.log10(BigDecimal, MathContext)
-
pi
public static java.math.BigDecimal pi()
Returns the number pi using the currentMathContext.- Returns:
- the number pi with the precision specified in the current
MathContext - See Also:
currentMathContext(),BigDecimalMath.pi(MathContext)
-
e
public static java.math.BigDecimal e()
Returns the number e using the currentMathContext.- Returns:
- the number e with the precision specified in the current
MathContext - See Also:
currentMathContext(),BigDecimalMath.e(MathContext)
-
exp
public static java.math.BigDecimal exp(java.math.BigDecimal x)
Calculates the natural exponent ofBigDecimalx (ex) using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the exponent for- Returns:
- the calculated exponent
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.exp(BigDecimal, MathContext)
-
sin
public static java.math.BigDecimal sin(java.math.BigDecimal x)
Calculates the sine (sinus) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the sine for- Returns:
- the calculated sine
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.sin(BigDecimal, MathContext)
-
asin
public static java.math.BigDecimal asin(java.math.BigDecimal x)
Calculates the arc sine (inverted sine) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the arc sine for- Returns:
- the calculated arc sine
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.asin(BigDecimal, MathContext)
-
cos
public static java.math.BigDecimal cos(java.math.BigDecimal x)
Calculates the cosine (cosinus) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the cosine for- Returns:
- the calculated cosine
BigDecimalwith the precision specified in the currentMathContext
-
acos
public static java.math.BigDecimal acos(java.math.BigDecimal x)
Calculates the arc cosine (inverted cosine) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the arc cosine for- Returns:
- the calculated arc sine
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.acos(BigDecimal, MathContext)
-
tan
public static java.math.BigDecimal tan(java.math.BigDecimal x)
Calculates the tangens ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the tangens for- Returns:
- the calculated tangens
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.tan(BigDecimal, MathContext)
-
atan
public static java.math.BigDecimal atan(java.math.BigDecimal x)
Calculates the arc tangens (inverted tangens) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the arc tangens for- Returns:
- the calculated arc tangens
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.atan(BigDecimal, MathContext)
-
atan2
public static java.math.BigDecimal atan2(java.math.BigDecimal y, java.math.BigDecimal x)Calculates the arc tangens (inverted tangens) ofBigDecimaly / x in the range -pi to pi using the currentMathContext.- Parameters:
y- theBigDecimalx- theBigDecimal- Returns:
- the calculated arc tangens
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),atan2(BigDecimal, BigDecimal)
-
cot
public static java.math.BigDecimal cot(java.math.BigDecimal x)
Calculates the cotangens ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the cotangens for- Returns:
- the calculated cotanges
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.cot(BigDecimal, MathContext)
-
acot
public static java.math.BigDecimal acot(java.math.BigDecimal x)
Calculates the inverse cotangens (arc cotangens) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the arc cotangens for- Returns:
- the calculated arc cotangens
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.acot(BigDecimal, MathContext)
-
sinh
public static java.math.BigDecimal sinh(java.math.BigDecimal x)
Calculates the hyperbolic sine ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the hyperbolic sine for- Returns:
- the calculated hyperbolic sine
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.sinh(BigDecimal, MathContext)
-
cosh
public static java.math.BigDecimal cosh(java.math.BigDecimal x)
Calculates the hyperbolic cosine ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the hyperbolic cosine for- Returns:
- the calculated hyperbolic cosine
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.cosh(BigDecimal, MathContext)
-
tanh
public static java.math.BigDecimal tanh(java.math.BigDecimal x)
Calculates the hyperbolic tangens ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the hyperbolic tangens for- Returns:
- the calculated hyperbolic tangens
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.tanh(BigDecimal, MathContext)
-
coth
public static java.math.BigDecimal coth(java.math.BigDecimal x)
Calculates the hyperbolic cotangens ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the hyperbolic cotangens for- Returns:
- the calculated hyperbolic cotangens
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.coth(BigDecimal, MathContext)
-
asinh
public static java.math.BigDecimal asinh(java.math.BigDecimal x)
Calculates the arc hyperbolic sine (inverse hyperbolic sine) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the arc hyperbolic sine for- Returns:
- the calculated arc hyperbolic sine
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.asinh(BigDecimal, MathContext)
-
acosh
public static java.math.BigDecimal acosh(java.math.BigDecimal x)
Calculates the arc hyperbolic cosine (inverse hyperbolic cosine) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the arc hyperbolic cosine for- Returns:
- the calculated arc hyperbolic cosine
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.acosh(BigDecimal, MathContext)
-
atanh
public static java.math.BigDecimal atanh(java.math.BigDecimal x)
Calculates the arc hyperbolic tangens (inverse hyperbolic tangens) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the arc hyperbolic tangens for- Returns:
- the calculated arc hyperbolic tangens
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.atanh(BigDecimal, MathContext)
-
acoth
public static java.math.BigDecimal acoth(java.math.BigDecimal x)
Calculates the arc hyperbolic cotangens (inverse hyperbolic cotangens) ofBigDecimalx using the currentMathContext.- Parameters:
x- theBigDecimalto calculate the arc hyperbolic cotangens for- Returns:
- the calculated arc hyperbolic cotangens
BigDecimalwith the precision specified in the currentMathContext - See Also:
currentMathContext(),BigDecimalMath.acoth(BigDecimal, MathContext)
-
-