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 aroundBigDecimal
which simplifies the consistent usage of theMathContext
and provides a simpler API for calculations.Overview
Every
BigFloat
instance has a reference to aBigFloat.Context
that specifies theMathContext
to 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 twoBigFloat
values 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
Context
specifying 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
Context
can then be used to create the first value of the calculation:BigFloat value1 = context.valueOf(640320);
The
BigFloat
instance 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
BigFloat
result 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 class
BigFloat.Context
Manages theMathContext
and provides factory methods forBigFloat
values.private static class
BigFloat.SpecialBigFloat
this class handle unrepresentable value in floating-point arithmetic
-
Field Summary
Fields Modifier and Type Field Description private BigFloat.Context
context
static BigFloat
NaN
Represents a value that is not a number.static BigFloat
NEGATIVE_INFINITY
Represents the positive infinity.static BigFloat
POSITIVE_INFINITY
Represents the positive infinity.private static long
serialVersionUID
private java.math.BigDecimal
value
-
Constructor Summary
Constructors Modifier Constructor Description private
BigFloat(java.math.BigDecimal value, BigFloat.Context context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BigFloat
abs(BigFloat x)
Returns theBigFloat
that is theabs(this)
(absolute value).static BigFloat
acos(BigFloat x)
Returns theBigFloat
that isacos(x)
.static BigFloat
acosh(BigFloat x)
Returns theBigFloat
that isacosh(x)
.static BigFloat
acot(BigFloat x)
Returns theBigFloat
that isacot(x)
.static BigFloat
acoth(BigFloat x)
Returns theBigFloat
that isacoth(x)
.BigFloat
add(double x)
Returns theBigFloat
that isthis + x
.BigFloat
add(int x)
Returns theBigFloat
that isthis + x
.BigFloat
add(long x)
Returns theBigFloat
that isthis + x
.BigFloat
add(BigFloat x)
Returns theBigFloat
that isthis + x
.BigFloat
add(java.math.BigDecimal x)
Returns theBigFloat
that isthis + x
.static BigFloat
asin(BigFloat x)
Returns theBigFloat
that isasin(x)
.static BigFloat
asinh(BigFloat x)
Returns theBigFloat
that isasinh(x)
.static BigFloat
atan(BigFloat x)
Returns theBigFloat
that isatan(x)
.static BigFloat
atanh(BigFloat x)
Returns theBigFloat
that isatanh(x)
.int
compareTo(BigFloat other)
static BigFloat.Context
context(int precision)
Creates aBigFloat.Context
with the specified precision andRoundingMode.HALF_UP
rounding.static BigFloat.Context
context(java.math.MathContext mathContext)
Creates aBigFloat.Context
with the specifiedMathContext
.static BigFloat
cos(BigFloat x)
Returns theBigFloat
that iscos(x)
.static BigFloat
cosh(BigFloat x)
Returns theBigFloat
that iscosh(x)
.static BigFloat
cot(BigFloat x)
Returns theBigFloat
that iscot(x)
.static BigFloat
coth(BigFloat x)
Returns theBigFloat
that iscoth(x)
.BigFloat
divide(double x)
Returns theBigFloat
that isthis / x
.BigFloat
divide(int x)
Returns theBigFloat
that isthis / x
.BigFloat
divide(long x)
Returns theBigFloat
that isthis / x
.BigFloat
divide(BigFloat x)
Returns theBigFloat
that isthis / x
.BigFloat
divide(java.math.BigDecimal x)
Returns theBigFloat
that isthis / x
.boolean
equals(java.lang.Object obj)
static BigFloat
exp(BigFloat x)
Returns theBigFloat
that isexp(x)
.BigFloat.Context
getContext()
Returns theBigFloat.Context
ofthis
value.BigFloat
getExponent()
Returns the exponent ofthis
value written as mantissa * 10exponent.BigFloat
getFractionalPart()
Returns the fractional part ofthis
value (right of the decimal point).BigFloat
getIntegralPart()
Returns the integral part ofthis
value (left of the decimal point).BigFloat
getMantissa()
Returns the mantissa ofthis
value written as mantissa * 10exponent.int
hashCode()
static boolean
isBetween(BigFloat min, BigFloat max, BigFloat value)
boolean
isDoubleValue()
Returns whetherthis
specifiedBigDecimal
value can be represented asdouble
.boolean
isEqual(BigFloat other)
Returns whetherthis
value is mathematically equal to theother
value.boolean
isGreaterThan(BigFloat other)
Returns whetherthis
value is mathematically greater than to theother
value.boolean
isGreaterThanOrEqual(BigFloat other)
Returns whetherthis
value is mathematically greater than or equal to theother
value.boolean
isInfinity()
boolean
isIntValue()
Returns whetherthis
value can be represented asint
.boolean
isLessThan(BigFloat other)
Returns whetherthis
value is mathematically less than to theother
value.boolean
isLessThanOrEqual(BigFloat other)
Returns whetherthis
value is mathematically less than or equal to theother
value.boolean
isNaN()
boolean
isNegative()
Returns whether thisBigFloat
is negative.boolean
isPositive()
Returns whether thisBigFloat
is positive.private static boolean
isRangeAbs1(BigFloat x)
protected boolean
isSpecial()
boolean
isZero()
Returns whether thisBigFloat
is 0.static BigFloat
log(BigFloat x)
Returns theBigFloat
that islog(x)
.static BigFloat
log10(BigFloat x)
Returns theBigFloat
that islog10(x)
.static BigFloat
log2(BigFloat x)
Returns theBigFloat
that islog2(x)
.private static BigFloat
logSpecial(BigFloat val)
private static BigFloat.Context
max(BigFloat.Context left, BigFloat.Context right)
static BigFloat
max(BigFloat value1, BigFloat value2)
Returns the the maximum of twoBigFloat
values.static BigFloat
max(BigFloat value1, BigFloat... values)
Returns the the maximum of nBigFloat
values.static BigFloat
min(BigFloat value1, BigFloat value2)
Returns the the minimum of twoBigFloat
values.static BigFloat
min(BigFloat value1, BigFloat... values)
Returns the the minimum of nBigFloat
values.BigFloat
multiply(double x)
Returns theBigFloat
that isthis * x
.BigFloat
multiply(int x)
Returns theBigFloat
that isthis * x
.BigFloat
multiply(long x)
Returns theBigFloat
that isthis * x
.BigFloat
multiply(BigFloat x)
Returns theBigFloat
that isthis * x
.BigFloat
multiply(java.math.BigDecimal x)
Returns theBigFloat
that isthis * x
.static BigFloat
negate(BigFloat x)
Returns theBigFloat
that is- this
.BigFloat
pow(double y)
BigFloat
pow(int y)
BigFloat
pow(long y)
BigFloat
pow(BigFloat y)
static BigFloat
pow(BigFloat x, BigFloat y)
Returns theBigFloat
that ispow(x, y)
.BigFloat
pow(java.math.BigDecimal y)
BigFloat
remainder(double x)
BigFloat
remainder(int x)
BigFloat
remainder(long x)
BigFloat
remainder(BigFloat x)
BigFloat
remainder(java.math.BigDecimal x)
BigFloat
root(double y)
BigFloat
root(int y)
BigFloat
root(long y)
BigFloat
root(BigFloat y)
static BigFloat
root(BigFloat x, BigFloat y)
Returns theBigFloat
that isroot(x, y)
.BigFloat
root(java.math.BigDecimal y)
int
signum()
Returns the signum function of thisBigFloat
.static BigFloat
sin(BigFloat x)
Returns theBigFloat
that issin(x)
.static BigFloat
sinh(BigFloat x)
Returns theBigFloat
that issinh(x)
.static BigFloat
sqrt(BigFloat x)
Returns theBigFloat
that issqrt(x)
.BigFloat
subtract(double x)
Returns theBigFloat
that isthis - x
.BigFloat
subtract(int x)
Returns theBigFloat
that isthis - x
.BigFloat
subtract(long x)
Returns theBigFloat
that isthis - x
.BigFloat
subtract(BigFloat x)
Returns theBigFloat
that isthis - x
.BigFloat
subtract(java.math.BigDecimal x)
Returns theBigFloat
that isthis - x
.static BigFloat
tan(BigFloat x)
Returns theBigFloat
that istan(x)
.static BigFloat
tanh(BigFloat x)
Returns theBigFloat
that istanh(x)
.java.math.BigDecimal
toBigDecimal()
Returnsthis
value as aBigDecimal
value.double
toDouble()
Returnsthis
value as adouble
value.int
toInt()
Returnsthis
value as aint
value.long
toLong()
Returnsthis
value as along
value.java.lang.String
toString()
protected BigFloat.SpecialBigFloat.Type
type()
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.Context
with the specified precision andRoundingMode.HALF_UP
rounding.- Parameters:
precision
- the precision- Returns:
- the
BigFloat.Context
-
context
public static BigFloat.Context context(java.math.MathContext mathContext)
Creates aBigFloat.Context
with the specifiedMathContext
.- Parameters:
mathContext
- theMathContext
- Returns:
- the
BigFloat.Context
-
add
public BigFloat add(BigFloat x)
Returns theBigFloat
that isthis + x
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that isthis - x
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that isthis * x
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that isthis / x
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that 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 theBigFloat
that is the remainder when dividingthis
byx
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with 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 theBigFloat
that isthis
to the power ofy
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with 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 theBigFloat
that is they
th root ofthis
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
signum
public int signum()
Returns the signum function of thisBigFloat
.- Returns:
- -1, 0, or 1 as the value of this
BigDecimal
is negative, zero, or positive.
-
isNegative
public boolean isNegative()
Returns whether thisBigFloat
is negative.- Returns:
true
if negative,false
if 0 or positive
-
isZero
public boolean isZero()
Returns whether thisBigFloat
is 0.- Returns:
true
if 0,false
if negative or positive
-
isPositive
public boolean isPositive()
Returns whether thisBigFloat
is positive.- Returns:
true
if positive,false
if 0 or negative
-
compareTo
public int compareTo(BigFloat other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<BigFloat>
-
isEqual
public boolean isEqual(BigFloat other)
Returns whetherthis
value is mathematically equal to theother
value.- Parameters:
other
- the otherBigFloat
to compare with- Returns:
true
if both values are mathematically equal (equivalent tothis.compareTo(other) == 0
- See Also:
compareTo(BigFloat)
-
isLessThan
public boolean isLessThan(BigFloat other)
Returns whetherthis
value is mathematically less than to theother
value.- Parameters:
other
- the otherBigFloat
to compare with- Returns:
true
this
value is mathematically less than to theother
value (equivalent tothis.compareTo(other) < 0
- See Also:
compareTo(BigFloat)
-
isGreaterThan
public boolean isGreaterThan(BigFloat other)
Returns whetherthis
value is mathematically greater than to theother
value.- Parameters:
other
- the otherBigFloat
to compare with- Returns:
true
this
value is mathematically greater than to theother
value (equivalent tothis.compareTo(other) > 0
- See Also:
compareTo(BigFloat)
-
isLessThanOrEqual
public boolean isLessThanOrEqual(BigFloat other)
Returns whetherthis
value is mathematically less than or equal to theother
value.- Parameters:
other
- the otherBigFloat
to compare with- Returns:
true
this
value is mathematically less than or equal to theother
value (equivalent tothis.compareTo(other) <= 0
- See Also:
compareTo(BigFloat)
,isLessThan(BigFloat)
,isEqual(BigFloat)
-
isGreaterThanOrEqual
public boolean isGreaterThanOrEqual(BigFloat other)
Returns whetherthis
value is mathematically greater than or equal to theother
value.- Parameters:
other
- the otherBigFloat
to compare with- Returns:
true
this
value is mathematically greater than or equal to theother
value (equivalent tothis.compareTo(other) >= 0
- See Also:
compareTo(BigFloat)
,isGreaterThan(BigFloat)
,isEqual(BigFloat)
-
isIntValue
public boolean isIntValue()
Returns whetherthis
value can be represented asint
.- Returns:
true
if the value can be represented asint
value- See Also:
BigDecimalMath.isIntValue(BigDecimal)
-
isDoubleValue
public boolean isDoubleValue()
Returns whetherthis
specifiedBigDecimal
value can be represented asdouble
.- Returns:
true
if the value can be represented asdouble
value- See Also:
BigDecimalMath.isDoubleValue(BigDecimal)
-
getMantissa
public BigFloat getMantissa()
Returns the mantissa ofthis
value 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 ofthis
value 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 ofthis
value (left of the decimal point).- Returns:
- the integral part
- See Also:
getFractionalPart()
,BigDecimalMath.fractionalPart(BigDecimal)
-
getFractionalPart
public BigFloat getFractionalPart()
Returns the fractional part ofthis
value (right of the decimal point).- Returns:
- the fractional part
- See Also:
getIntegralPart()
,BigDecimalMath.fractionalPart(BigDecimal)
-
getContext
public BigFloat.Context getContext()
Returns theBigFloat.Context
ofthis
value.- Returns:
- the
BigFloat.Context
-
toBigDecimal
public java.math.BigDecimal toBigDecimal()
Returnsthis
value as aBigDecimal
value.- Returns:
- the
BigDecimal
value
-
toDouble
public double toDouble()
Returnsthis
value as adouble
value.- Returns:
- the
double
value - See Also:
BigDecimal.doubleValue()
-
toLong
public long toLong()
Returnsthis
value as along
value.- Returns:
- the
long
value - See Also:
BigDecimal.longValue()
-
toInt
public int toInt()
Returnsthis
value as aint
value.- Returns:
- the
int
value - See Also:
BigDecimal.intValue()
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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 theBigFloat
that 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 theBigFloat
that 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 twoBigFloat
values.
-
max
public static BigFloat max(BigFloat value1, BigFloat... values)
Returns the the maximum of nBigFloat
values.
-
min
public static BigFloat min(BigFloat value1, BigFloat value2)
Returns the the minimum of twoBigFloat
values.
-
min
public static BigFloat min(BigFloat value1, BigFloat... values)
Returns the the minimum of nBigFloat
values.
-
log
public static BigFloat log(BigFloat x)
Returns theBigFloat
that islog(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.log(BigDecimal, MathContext)
-
log2
public static BigFloat log2(BigFloat x)
Returns theBigFloat
that islog2(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.log2(BigDecimal, MathContext)
-
log10
public static BigFloat log10(BigFloat x)
Returns theBigFloat
that islog10(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.log10(BigDecimal, MathContext)
-
exp
public static BigFloat exp(BigFloat x)
Returns theBigFloat
that isexp(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.exp(BigDecimal, MathContext)
-
sqrt
public static BigFloat sqrt(BigFloat x)
Returns theBigFloat
that 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 theBigFloat
that ispow(x, y)
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with the larger precision.- Parameters:
x
- theBigFloat
value to take to the powery
- theBigFloat
value 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 theBigFloat
that isroot(x, y)
.If the two values do not have the same
BigFloat.Context
, the result will contain theBigFloat.Context
with the larger precision.- Parameters:
x
- theBigFloat
value to calculate the n'th rooty
- theBigFloat
defining the root- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
-
sin
public static BigFloat sin(BigFloat x)
Returns theBigFloat
that issin(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.sin(BigDecimal, MathContext)
-
cos
public static BigFloat cos(BigFloat x)
Returns theBigFloat
that iscos(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.cos(BigDecimal, MathContext)
-
tan
public static BigFloat tan(BigFloat x)
Returns theBigFloat
that istan(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.tan(BigDecimal, MathContext)
-
cot
public static BigFloat cot(BigFloat x)
Returns theBigFloat
that iscot(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.cot(BigDecimal, MathContext)
-
asin
public static BigFloat asin(BigFloat x)
Returns theBigFloat
that isasin(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.asin(BigDecimal, MathContext)
-
acos
public static BigFloat acos(BigFloat x)
Returns theBigFloat
that 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 theBigFloat
that isatan(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.atan(BigDecimal, MathContext)
-
acot
public static BigFloat acot(BigFloat x)
Returns theBigFloat
that isacot(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.acot(BigDecimal, MathContext)
-
sinh
public static BigFloat sinh(BigFloat x)
Returns theBigFloat
that issinh(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.sinh(BigDecimal, MathContext)
-
cosh
public static BigFloat cosh(BigFloat x)
Returns theBigFloat
that iscosh(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.cosh(BigDecimal, MathContext)
-
tanh
public static BigFloat tanh(BigFloat x)
Returns theBigFloat
that istanh(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.tanh(BigDecimal, MathContext)
-
coth
public static BigFloat coth(BigFloat x)
Returns theBigFloat
that iscoth(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.coth(BigDecimal, MathContext)
-
asinh
public static BigFloat asinh(BigFloat x)
Returns theBigFloat
that isasinh(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.asinh(BigDecimal, MathContext)
-
acosh
public static BigFloat acosh(BigFloat x)
Returns theBigFloat
that isacosh(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.acosh(BigDecimal, MathContext)
-
atanh
public static BigFloat atanh(BigFloat x)
Returns theBigFloat
that isatanh(x)
.- Parameters:
x
- the value- Returns:
- the resulting
BigFloat
- See Also:
BigDecimalMath.atanh(BigDecimal, MathContext)
-
acoth
public static BigFloat acoth(BigFloat x)
Returns theBigFloat
that 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)
-
-