Class BigFloat
- java.lang.Object
-
- ch.obermuhlner.math.big.BigFloat
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<BigFloat>
- Direct Known Subclasses:
BigFloat.SpecialBigFloat
public class BigFloat extends java.lang.Object implements java.lang.Comparable<BigFloat>, java.io.Serializable
A wrapper aroundBigDecimalwhich simplifies the consistent usage of theMathContextand provides a simpler API for calculations.Overview
Every
BigFloatinstance has a reference to aBigFloat.Contextthat specifies theMathContextto be used for all calculations and values.The API for calculations is simplified and more consistent with the typical mathematical usage.
- Factory methods for values:
valueOf(BigFloat)valueOf(BigDecimal)valueOf(int)valueOf(long)valueOf(double)valueOf(String)pi()e()
- All standard operators:
add(x)subtract(x)multiply(x)remainder(x)pow(y)root(y)
- Calculation methods are overloaded for different value types:
add(BigFloat)add(BigDecimal)add(int)add(long)add(double)- ...
- Mathematical functions are written as they are traditionally are written:
abs(x)log(x)sin(x)min(x1, x2, ...)max(x1, x2, ...)- ...
- Support for advanced mathematical functions:
sqrt(x)log(x)exp(x)sin(x)cos(x)tan(x)- ...
- Methods to access parts of a value:
getMantissa()getExponent()getIntegralPart()getFractionalPart()
- Equals and Hashcode methods:
equals(Object)that returns whether twoBigFloatvalues are mathematically the samehashCode()consistent withequals(Object)
- Comparison methods:
isEqual(BigFloat)isLessThan(BigFloat)isLessThanOrEqual(BigFloat)isGreaterThan(BigFloat)isGreaterThanOrEqual(BigFloat)
Usage
Before doing any calculations you need to create a
Contextspecifying the precision used for all calculations.Context context = BigFloat.context(100); // precision of 100 digits Context anotherContext = BigFloat.context(new MathContext(10, RoundingMode.HALF_UP); // precision of 10 digits, rounding half up
The
Contextcan then be used to create the first value of the calculation:BigFloat value1 = context.valueOf(640320);
The
BigFloatinstance holds a reference to theContext. This context is then passed from calculation to calculation.BigFloat value2 = context.valueOf(640320).pow(3).divide(24); BigFloat value3 = BigFloat.sin(value2);
The
BigFloatresult can be converted to other numerical types:BigDecimal bigDecimalValue = value3.toBigDecimal(); double doubleValue = value3.toDouble(); long longValue = value3.toLong(); int intValue = value3.toInt();
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBigFloat.ContextManages theMathContextand provides factory methods forBigFloatvalues.private static classBigFloat.SpecialBigFloatthis class handle unrepresentable value in floating-point arithmetic
-
Field Summary
Fields Modifier and Type Field Description private BigFloat.Contextcontextstatic BigFloatNaNRepresents a value that is not a number.static BigFloatNEGATIVE_INFINITYRepresents the positive infinity.static BigFloatPOSITIVE_INFINITYRepresents the positive infinity.private static longserialVersionUIDprivate java.math.BigDecimalvalue
-
Constructor Summary
Constructors Modifier Constructor Description privateBigFloat(java.math.BigDecimal value, BigFloat.Context context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BigFloatabs(BigFloat x)Returns theBigFloatthat is theabs(this)(absolute value).static BigFloatacos(BigFloat x)Returns theBigFloatthat isacos(x).static BigFloatacosh(BigFloat x)Returns theBigFloatthat isacosh(x).static BigFloatacot(BigFloat x)Returns theBigFloatthat isacot(x).static BigFloatacoth(BigFloat x)Returns theBigFloatthat isacoth(x).BigFloatadd(double x)Returns theBigFloatthat isthis + x.BigFloatadd(int x)Returns theBigFloatthat isthis + x.BigFloatadd(long x)Returns theBigFloatthat isthis + x.BigFloatadd(BigFloat x)Returns theBigFloatthat isthis + x.BigFloatadd(java.math.BigDecimal x)Returns theBigFloatthat isthis + x.static BigFloatasin(BigFloat x)Returns theBigFloatthat isasin(x).static BigFloatasinh(BigFloat x)Returns theBigFloatthat isasinh(x).static BigFloatatan(BigFloat x)Returns theBigFloatthat isatan(x).static BigFloatatanh(BigFloat x)Returns theBigFloatthat isatanh(x).intcompareTo(BigFloat other)static BigFloat.Contextcontext(int precision)Creates aBigFloat.Contextwith the specified precision andRoundingMode.HALF_UProunding.static BigFloat.Contextcontext(java.math.MathContext mathContext)Creates aBigFloat.Contextwith the specifiedMathContext.static BigFloatcos(BigFloat x)Returns theBigFloatthat iscos(x).static BigFloatcosh(BigFloat x)Returns theBigFloatthat iscosh(x).static BigFloatcot(BigFloat x)Returns theBigFloatthat iscot(x).static BigFloatcoth(BigFloat x)Returns theBigFloatthat iscoth(x).BigFloatdivide(double x)Returns theBigFloatthat isthis / x.BigFloatdivide(int x)Returns theBigFloatthat isthis / x.BigFloatdivide(long x)Returns theBigFloatthat isthis / x.BigFloatdivide(BigFloat x)Returns theBigFloatthat isthis / x.BigFloatdivide(java.math.BigDecimal x)Returns theBigFloatthat isthis / x.booleanequals(java.lang.Object obj)static BigFloatexp(BigFloat x)Returns theBigFloatthat isexp(x).BigFloat.ContextgetContext()Returns theBigFloat.Contextofthisvalue.BigFloatgetExponent()Returns the exponent ofthisvalue written as mantissa * 10exponent.BigFloatgetFractionalPart()Returns the fractional part ofthisvalue (right of the decimal point).BigFloatgetIntegralPart()Returns the integral part ofthisvalue (left of the decimal point).BigFloatgetMantissa()Returns the mantissa ofthisvalue written as mantissa * 10exponent.inthashCode()static booleanisBetween(BigFloat min, BigFloat max, BigFloat value)booleanisDoubleValue()Returns whetherthisspecifiedBigDecimalvalue can be represented asdouble.booleanisEqual(BigFloat other)Returns whetherthisvalue is mathematically equal to theothervalue.booleanisGreaterThan(BigFloat other)Returns whetherthisvalue is mathematically greater than to theothervalue.booleanisGreaterThanOrEqual(BigFloat other)Returns whetherthisvalue is mathematically greater than or equal to theothervalue.booleanisInfinity()booleanisIntValue()Returns whetherthisvalue can be represented asint.booleanisLessThan(BigFloat other)Returns whetherthisvalue is mathematically less than to theothervalue.booleanisLessThanOrEqual(BigFloat other)Returns whetherthisvalue is mathematically less than or equal to theothervalue.booleanisNaN()booleanisNegative()Returns whether thisBigFloatis negative.booleanisPositive()Returns whether thisBigFloatis positive.private static booleanisRangeAbs1(BigFloat x)protected booleanisSpecial()booleanisZero()Returns whether thisBigFloatis 0.static BigFloatlog(BigFloat x)Returns theBigFloatthat islog(x).static BigFloatlog10(BigFloat x)Returns theBigFloatthat islog10(x).static BigFloatlog2(BigFloat x)Returns theBigFloatthat islog2(x).private static BigFloatlogSpecial(BigFloat val)private static BigFloat.Contextmax(BigFloat.Context left, BigFloat.Context right)static BigFloatmax(BigFloat value1, BigFloat value2)Returns the the maximum of twoBigFloatvalues.static BigFloatmax(BigFloat value1, BigFloat... values)Returns the the maximum of nBigFloatvalues.static BigFloatmin(BigFloat value1, BigFloat value2)Returns the the minimum of twoBigFloatvalues.static BigFloatmin(BigFloat value1, BigFloat... values)Returns the the minimum of nBigFloatvalues.BigFloatmultiply(double x)Returns theBigFloatthat isthis * x.BigFloatmultiply(int x)Returns theBigFloatthat isthis * x.BigFloatmultiply(long x)Returns theBigFloatthat isthis * x.BigFloatmultiply(BigFloat x)Returns theBigFloatthat isthis * x.BigFloatmultiply(java.math.BigDecimal x)Returns theBigFloatthat isthis * x.static BigFloatnegate(BigFloat x)Returns theBigFloatthat is- this.BigFloatpow(double y)BigFloatpow(int y)BigFloatpow(long y)BigFloatpow(BigFloat y)static BigFloatpow(BigFloat x, BigFloat y)Returns theBigFloatthat ispow(x, y).BigFloatpow(java.math.BigDecimal y)BigFloatremainder(double x)BigFloatremainder(int x)BigFloatremainder(long x)BigFloatremainder(BigFloat x)BigFloatremainder(java.math.BigDecimal x)BigFloatroot(double y)BigFloatroot(int y)BigFloatroot(long y)BigFloatroot(BigFloat y)static BigFloatroot(BigFloat x, BigFloat y)Returns theBigFloatthat isroot(x, y).BigFloatroot(java.math.BigDecimal y)intsignum()Returns the signum function of thisBigFloat.static BigFloatsin(BigFloat x)Returns theBigFloatthat issin(x).static BigFloatsinh(BigFloat x)Returns theBigFloatthat issinh(x).static BigFloatsqrt(BigFloat x)Returns theBigFloatthat issqrt(x).BigFloatsubtract(double x)Returns theBigFloatthat isthis - x.BigFloatsubtract(int x)Returns theBigFloatthat isthis - x.BigFloatsubtract(long x)Returns theBigFloatthat isthis - x.BigFloatsubtract(BigFloat x)Returns theBigFloatthat isthis - x.BigFloatsubtract(java.math.BigDecimal x)Returns theBigFloatthat isthis - x.static BigFloattan(BigFloat x)Returns theBigFloatthat istan(x).static BigFloattanh(BigFloat x)Returns theBigFloatthat istanh(x).java.math.BigDecimaltoBigDecimal()Returnsthisvalue as aBigDecimalvalue.doubletoDouble()Returnsthisvalue as adoublevalue.inttoInt()Returnsthisvalue as aintvalue.longtoLong()Returnsthisvalue as alongvalue.java.lang.StringtoString()protected BigFloat.SpecialBigFloat.Typetype()return special type of a value
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
NaN
public static final BigFloat NaN
Represents a value that is not a number.- See Also:
Double.NaN
-
POSITIVE_INFINITY
public static final BigFloat POSITIVE_INFINITY
Represents the positive infinity.- See Also:
Double.POSITIVE_INFINITY
-
NEGATIVE_INFINITY
public static final BigFloat NEGATIVE_INFINITY
Represents the positive infinity.- See Also:
Double.NEGATIVE_INFINITY
-
value
private final java.math.BigDecimal value
-
context
private final BigFloat.Context context
-
-
Constructor Detail
-
BigFloat
private BigFloat(java.math.BigDecimal value, BigFloat.Context context)
-
-
Method Detail
-
context
public static BigFloat.Context context(int precision)
Creates aBigFloat.Contextwith the specified precision andRoundingMode.HALF_UProunding.- Parameters:
precision- the precision- Returns:
- the
BigFloat.Context
-
context
public static BigFloat.Context context(java.math.MathContext mathContext)
Creates aBigFloat.Contextwith the specifiedMathContext.- Parameters:
mathContext- theMathContext- Returns:
- the
BigFloat.Context
-
add
public BigFloat add(BigFloat x)
Returns theBigFloatthat isthis + x.If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
x- the value to add- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.add(BigDecimal, MathContext)
-
add
public BigFloat add(java.math.BigDecimal x)
Returns theBigFloatthat isthis + x.- Parameters:
x- the value to add- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.add(BigDecimal, MathContext)
-
add
public BigFloat add(int x)
Returns theBigFloatthat isthis + x.- Parameters:
x- the value to add- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.add(BigDecimal, MathContext)
-
add
public BigFloat add(long x)
Returns theBigFloatthat isthis + x.- Parameters:
x- the value to add- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.add(BigDecimal, MathContext)
-
add
public BigFloat add(double x)
Returns theBigFloatthat isthis + x.- Parameters:
x- the value to add- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.add(BigDecimal, MathContext)
-
subtract
public BigFloat subtract(BigFloat x)
Returns theBigFloatthat isthis - x.If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
x- the value to subtract- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.subtract(BigDecimal, MathContext)
-
subtract
public BigFloat subtract(java.math.BigDecimal x)
Returns theBigFloatthat isthis - x.- Parameters:
x- the value to subtract- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.subtract(BigDecimal, MathContext)
-
subtract
public BigFloat subtract(int x)
Returns theBigFloatthat isthis - x.- Parameters:
x- the value to subtract- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.subtract(BigDecimal, MathContext)
-
subtract
public BigFloat subtract(long x)
Returns theBigFloatthat isthis - x.- Parameters:
x- the value to subtract- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.subtract(BigDecimal, MathContext)
-
subtract
public BigFloat subtract(double x)
Returns theBigFloatthat isthis - x.- Parameters:
x- the value to subtract- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.subtract(BigDecimal, MathContext)
-
multiply
public BigFloat multiply(BigFloat x)
Returns theBigFloatthat isthis * x.If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
x- the value to multiply- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.multiply(BigDecimal, MathContext)
-
multiply
public BigFloat multiply(java.math.BigDecimal x)
Returns theBigFloatthat isthis * x.- Parameters:
x- the value to multiply- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.multiply(BigDecimal, MathContext)
-
multiply
public BigFloat multiply(int x)
Returns theBigFloatthat isthis * x.- Parameters:
x- the value to multiply- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.multiply(BigDecimal, MathContext)
-
multiply
public BigFloat multiply(long x)
Returns theBigFloatthat isthis * x.- Parameters:
x- the value to multiply- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.multiply(BigDecimal, MathContext)
-
multiply
public BigFloat multiply(double x)
Returns theBigFloatthat isthis * x.- Parameters:
x- the value to multiply- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.multiply(BigDecimal, MathContext)
-
divide
public BigFloat divide(BigFloat x)
Returns theBigFloatthat isthis / x.If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.divide(BigDecimal, MathContext)
-
divide
public BigFloat divide(java.math.BigDecimal x)
Returns theBigFloatthat isthis / x.- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.divide(BigDecimal, MathContext)
-
divide
public BigFloat divide(int x)
Returns theBigFloatthat isthis / x.- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.divide(BigDecimal, MathContext)
-
divide
public BigFloat divide(long x)
Returns theBigFloatthat isthis / x.- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.divide(BigDecimal, MathContext)
-
divide
public BigFloat divide(double x)
Returns theBigFloatthat isthis / x.- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.divide(BigDecimal, MathContext)
-
remainder
public BigFloat remainder(BigFloat x)
Returns theBigFloatthat is the remainder when dividingthisbyx.If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.remainder(BigDecimal, MathContext)
-
remainder
public BigFloat remainder(java.math.BigDecimal x)
- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.remainder(BigDecimal, MathContext)
-
remainder
public BigFloat remainder(int x)
- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.remainder(BigDecimal, MathContext)
-
remainder
public BigFloat remainder(long x)
- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.remainder(BigDecimal, MathContext)
-
remainder
public BigFloat remainder(double x)
- Parameters:
x- the value to divide with- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.remainder(BigDecimal, MathContext)
-
pow
public BigFloat pow(BigFloat y)
Returns theBigFloatthat isthisto the power ofy.If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
y- the value of the power- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
pow
public BigFloat pow(java.math.BigDecimal y)
- Parameters:
y- the value of the power- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
pow
public BigFloat pow(int y)
- Parameters:
y- the value of the power- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
pow
public BigFloat pow(long y)
- Parameters:
y- the value of the power- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
pow
public BigFloat pow(double y)
- Parameters:
y- the value of the power- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
root
public BigFloat root(BigFloat y)
Returns theBigFloatthat is theyth root ofthis.If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
y- the value of the root- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)
-
root
public BigFloat root(java.math.BigDecimal y)
- Parameters:
y- the value of the root- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)
-
root
public BigFloat root(int y)
- Parameters:
y- the value of the root- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)
-
root
public BigFloat root(long y)
- Parameters:
y- the value of the root- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)
-
root
public BigFloat root(double y)
- Parameters:
y- the value of the root- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
signum
public int signum()
Returns the signum function of thisBigFloat.- Returns:
- -1, 0, or 1 as the value of this
BigDecimalis negative, zero, or positive.
-
isNegative
public boolean isNegative()
Returns whether thisBigFloatis negative.- Returns:
trueif negative,falseif 0 or positive
-
isZero
public boolean isZero()
Returns whether thisBigFloatis 0.- Returns:
trueif 0,falseif negative or positive
-
isPositive
public boolean isPositive()
Returns whether thisBigFloatis positive.- Returns:
trueif positive,falseif 0 or negative
-
compareTo
public int compareTo(BigFloat other)
- Specified by:
compareToin interfacejava.lang.Comparable<BigFloat>
-
isEqual
public boolean isEqual(BigFloat other)
Returns whetherthisvalue is mathematically equal to theothervalue.- Parameters:
other- the otherBigFloatto compare with- Returns:
trueif both values are mathematically equal (equivalent tothis.compareTo(other) == 0- See Also:
compareTo(BigFloat)
-
isLessThan
public boolean isLessThan(BigFloat other)
Returns whetherthisvalue is mathematically less than to theothervalue.- Parameters:
other- the otherBigFloatto compare with- Returns:
truethisvalue is mathematically less than to theothervalue (equivalent tothis.compareTo(other) < 0- See Also:
compareTo(BigFloat)
-
isGreaterThan
public boolean isGreaterThan(BigFloat other)
Returns whetherthisvalue is mathematically greater than to theothervalue.- Parameters:
other- the otherBigFloatto compare with- Returns:
truethisvalue is mathematically greater than to theothervalue (equivalent tothis.compareTo(other) > 0- See Also:
compareTo(BigFloat)
-
isLessThanOrEqual
public boolean isLessThanOrEqual(BigFloat other)
Returns whetherthisvalue is mathematically less than or equal to theothervalue.- Parameters:
other- the otherBigFloatto compare with- Returns:
truethisvalue is mathematically less than or equal to theothervalue (equivalent tothis.compareTo(other) <= 0- See Also:
compareTo(BigFloat),isLessThan(BigFloat),isEqual(BigFloat)
-
isGreaterThanOrEqual
public boolean isGreaterThanOrEqual(BigFloat other)
Returns whetherthisvalue is mathematically greater than or equal to theothervalue.- Parameters:
other- the otherBigFloatto compare with- Returns:
truethisvalue is mathematically greater than or equal to theothervalue (equivalent tothis.compareTo(other) >= 0- See Also:
compareTo(BigFloat),isGreaterThan(BigFloat),isEqual(BigFloat)
-
isIntValue
public boolean isIntValue()
Returns whetherthisvalue can be represented asint.- Returns:
trueif the value can be represented asintvalue- See Also:
BigDecimalMath.isIntValue(BigDecimal)
-
isDoubleValue
public boolean isDoubleValue()
Returns whetherthisspecifiedBigDecimalvalue can be represented asdouble.- Returns:
trueif the value can be represented asdoublevalue- See Also:
BigDecimalMath.isDoubleValue(BigDecimal)
-
getMantissa
public BigFloat getMantissa()
Returns the mantissa ofthisvalue written as mantissa * 10exponent.The mantissa is defined as having exactly 1 digit before the decimal point.
- Returns:
- the mantissa
- See Also:
getExponent(),BigDecimalMath.mantissa(BigDecimal)
-
getExponent
public BigFloat getExponent()
Returns the exponent ofthisvalue written as mantissa * 10exponent.The mantissa is defined as having exactly 1 digit before the decimal point.
- Returns:
- the exponent
- See Also:
getMantissa(),BigDecimalMath.exponent(BigDecimal)
-
getIntegralPart
public BigFloat getIntegralPart()
Returns the integral part ofthisvalue (left of the decimal point).- Returns:
- the integral part
- See Also:
getFractionalPart(),BigDecimalMath.fractionalPart(BigDecimal)
-
getFractionalPart
public BigFloat getFractionalPart()
Returns the fractional part ofthisvalue (right of the decimal point).- Returns:
- the fractional part
- See Also:
getIntegralPart(),BigDecimalMath.fractionalPart(BigDecimal)
-
getContext
public BigFloat.Context getContext()
Returns theBigFloat.Contextofthisvalue.- Returns:
- the
BigFloat.Context
-
toBigDecimal
public java.math.BigDecimal toBigDecimal()
Returnsthisvalue as aBigDecimalvalue.- Returns:
- the
BigDecimalvalue
-
toDouble
public double toDouble()
Returnsthisvalue as adoublevalue.- Returns:
- the
doublevalue - See Also:
BigDecimal.doubleValue()
-
toLong
public long toLong()
Returnsthisvalue as alongvalue.- Returns:
- the
longvalue - See Also:
BigDecimal.longValue()
-
toInt
public int toInt()
Returnsthisvalue as aintvalue.- Returns:
- the
intvalue - See Also:
BigDecimal.intValue()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isSpecial
protected boolean isSpecial()
-
type
protected BigFloat.SpecialBigFloat.Type type()
return special type of a value- Returns:
BigFloat.SpecialBigFloat.Type
-
isNaN
public boolean isNaN()
-
isInfinity
public boolean isInfinity()
-
negate
public static BigFloat negate(BigFloat x)
Returns theBigFloatthat is- this.- Parameters:
x- the value to negate- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.negate(MathContext)
-
abs
public static BigFloat abs(BigFloat x)
Returns theBigFloatthat is theabs(this)(absolute value).- Parameters:
x- the value to make absolute- Returns:
- the resulting
BigFloat - See Also:
BigDecimal.abs(MathContext)
-
max
public static BigFloat max(BigFloat value1, BigFloat value2)
Returns the the maximum of twoBigFloatvalues.
-
max
public static BigFloat max(BigFloat value1, BigFloat... values)
Returns the the maximum of nBigFloatvalues.
-
min
public static BigFloat min(BigFloat value1, BigFloat value2)
Returns the the minimum of twoBigFloatvalues.
-
min
public static BigFloat min(BigFloat value1, BigFloat... values)
Returns the the minimum of nBigFloatvalues.
-
log
public static BigFloat log(BigFloat x)
Returns theBigFloatthat islog(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.log(BigDecimal, MathContext)
-
log2
public static BigFloat log2(BigFloat x)
Returns theBigFloatthat islog2(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.log2(BigDecimal, MathContext)
-
log10
public static BigFloat log10(BigFloat x)
Returns theBigFloatthat islog10(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.log10(BigDecimal, MathContext)
-
exp
public static BigFloat exp(BigFloat x)
Returns theBigFloatthat isexp(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.exp(BigDecimal, MathContext)
-
sqrt
public static BigFloat sqrt(BigFloat x)
Returns theBigFloatthat issqrt(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.sqrt(BigDecimal, MathContext)
-
pow
public static BigFloat pow(BigFloat x, BigFloat y)
Returns theBigFloatthat ispow(x, y).If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
x- theBigFloatvalue to take to the powery- theBigFloatvalue to serve as exponent- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
root
public static BigFloat root(BigFloat x, BigFloat y)
Returns theBigFloatthat isroot(x, y).If the two values do not have the same
BigFloat.Context, the result will contain theBigFloat.Contextwith the larger precision.- Parameters:
x- theBigFloatvalue to calculate the n'th rooty- theBigFloatdefining the root- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
sin
public static BigFloat sin(BigFloat x)
Returns theBigFloatthat issin(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.sin(BigDecimal, MathContext)
-
cos
public static BigFloat cos(BigFloat x)
Returns theBigFloatthat iscos(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.cos(BigDecimal, MathContext)
-
tan
public static BigFloat tan(BigFloat x)
Returns theBigFloatthat istan(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.tan(BigDecimal, MathContext)
-
cot
public static BigFloat cot(BigFloat x)
Returns theBigFloatthat iscot(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.cot(BigDecimal, MathContext)
-
asin
public static BigFloat asin(BigFloat x)
Returns theBigFloatthat isasin(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.asin(BigDecimal, MathContext)
-
acos
public static BigFloat acos(BigFloat x)
Returns theBigFloatthat isacos(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.acos(BigDecimal, MathContext)
-
isRangeAbs1
private static boolean isRangeAbs1(BigFloat x)
- Parameters:
x- a bigfloat- Returns:
- if abs(x) <= 1
-
atan
public static BigFloat atan(BigFloat x)
Returns theBigFloatthat isatan(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.atan(BigDecimal, MathContext)
-
acot
public static BigFloat acot(BigFloat x)
Returns theBigFloatthat isacot(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.acot(BigDecimal, MathContext)
-
sinh
public static BigFloat sinh(BigFloat x)
Returns theBigFloatthat issinh(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.sinh(BigDecimal, MathContext)
-
cosh
public static BigFloat cosh(BigFloat x)
Returns theBigFloatthat iscosh(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.cosh(BigDecimal, MathContext)
-
tanh
public static BigFloat tanh(BigFloat x)
Returns theBigFloatthat istanh(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.tanh(BigDecimal, MathContext)
-
coth
public static BigFloat coth(BigFloat x)
Returns theBigFloatthat iscoth(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.coth(BigDecimal, MathContext)
-
asinh
public static BigFloat asinh(BigFloat x)
Returns theBigFloatthat isasinh(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.asinh(BigDecimal, MathContext)
-
acosh
public static BigFloat acosh(BigFloat x)
Returns theBigFloatthat isacosh(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.acosh(BigDecimal, MathContext)
-
atanh
public static BigFloat atanh(BigFloat x)
Returns theBigFloatthat isatanh(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.atanh(BigDecimal, MathContext)
-
acoth
public static BigFloat acoth(BigFloat x)
Returns theBigFloatthat isacoth(x).- Parameters:
x- the value- Returns:
- the resulting
BigFloat - See Also:
BigDecimalMath.acoth(BigDecimal, MathContext)
-
max
private static BigFloat.Context max(BigFloat.Context left, BigFloat.Context right)
-
-