Class BigReal
- java.lang.Object
-
- org.apache.commons.math4.legacy.linear.BigReal
-
- All Implemented Interfaces:
Serializable,Comparable<BigReal>,FieldElement<BigReal>
public class BigReal extends Object implements FieldElement<BigReal>, Comparable<BigReal>, Serializable
Arbitrary precision decimal number.This class is a simple wrapper around the standard
BigDecimalin order to implement theFieldElementinterface.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BigReal(char[] in)Build an instance from a characters representation.BigReal(char[] in, int offset, int len)Build an instance from a characters representation.BigReal(char[] in, int offset, int len, MathContext mc)Build an instance from a characters representation.BigReal(char[] in, MathContext mc)Build an instance from a characters representation.BigReal(double val)Build an instance from a double.BigReal(double val, MathContext mc)Build an instance from a double.BigReal(int val)Build an instance from an int.BigReal(int val, MathContext mc)Build an instance from an int.BigReal(long val)Build an instance from a long.BigReal(long val, MathContext mc)Build an instance from a long.BigReal(String val)Build an instance from a String representation.BigReal(String val, MathContext mc)Build an instance from a String representation.BigReal(BigDecimal val)Build an instance from a BigDecimal.BigReal(BigInteger val)Build an instance from a BigInteger.BigReal(BigInteger unscaledVal, int scale)Build an instance from an unscaled BigInteger.BigReal(BigInteger unscaledVal, int scale, MathContext mc)Build an instance from an unscaled BigInteger.BigReal(BigInteger val, MathContext mc)Build an instance from a BigInteger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigRealadd(BigReal a)BigDecimalbigDecimalValue()Get the BigDecimal value corresponding to the instance.intcompareTo(BigReal a)BigRealdivide(BigReal a)doubledoubleValue()Get the double value corresponding to the instance.booleanequals(Object other)Field<BigReal>getField()RoundingModegetRoundingMode()Gets the rounding mode for division operations.intgetScale()Sets the scale for division operations.inthashCode()BigRealmultiply(int n)BigRealmultiply(BigReal a)BigRealnegate()BigRealreciprocal()voidsetRoundingMode(RoundingMode roundingMode)Sets the rounding mode for decimal divisions.voidsetScale(int scale)Sets the scale for division operations.BigRealsubtract(BigReal a)
-
-
-
Constructor Detail
-
BigReal
public BigReal(BigDecimal val)
Build an instance from a BigDecimal.- Parameters:
val- value of the instance
-
BigReal
public BigReal(BigInteger val)
Build an instance from a BigInteger.- Parameters:
val- value of the instance
-
BigReal
public BigReal(BigInteger unscaledVal, int scale)
Build an instance from an unscaled BigInteger.- Parameters:
unscaledVal- unscaled valuescale- scale to use
-
BigReal
public BigReal(BigInteger unscaledVal, int scale, MathContext mc)
Build an instance from an unscaled BigInteger.- Parameters:
unscaledVal- unscaled valuescale- scale to usemc- to used
-
BigReal
public BigReal(BigInteger val, MathContext mc)
Build an instance from a BigInteger.- Parameters:
val- value of the instancemc- context to use
-
BigReal
public BigReal(char[] in)
Build an instance from a characters representation.- Parameters:
in- character representation of the value
-
BigReal
public BigReal(char[] in, int offset, int len)
Build an instance from a characters representation.- Parameters:
in- character representation of the valueoffset- offset of the first character to analyzelen- length of the array slice to analyze
-
BigReal
public BigReal(char[] in, int offset, int len, MathContext mc)
Build an instance from a characters representation.- Parameters:
in- character representation of the valueoffset- offset of the first character to analyzelen- length of the array slice to analyzemc- context to use
-
BigReal
public BigReal(char[] in, MathContext mc)
Build an instance from a characters representation.- Parameters:
in- character representation of the valuemc- context to use
-
BigReal
public BigReal(double val)
Build an instance from a double.- Parameters:
val- value of the instance
-
BigReal
public BigReal(double val, MathContext mc)
Build an instance from a double.- Parameters:
val- value of the instancemc- context to use
-
BigReal
public BigReal(int val)
Build an instance from an int.- Parameters:
val- value of the instance
-
BigReal
public BigReal(int val, MathContext mc)
Build an instance from an int.- Parameters:
val- value of the instancemc- context to use
-
BigReal
public BigReal(long val)
Build an instance from a long.- Parameters:
val- value of the instance
-
BigReal
public BigReal(long val, MathContext mc)
Build an instance from a long.- Parameters:
val- value of the instancemc- context to use
-
BigReal
public BigReal(String val)
Build an instance from a String representation.- Parameters:
val- character representation of the value
-
BigReal
public BigReal(String val, MathContext mc)
Build an instance from a String representation.- Parameters:
val- character representation of the valuemc- context to use
-
-
Method Detail
-
getRoundingMode
public RoundingMode getRoundingMode()
Gets the rounding mode for division operations. The default isRoundingMode.HALF_UP- Returns:
- the rounding mode.
- Since:
- 2.1
-
setRoundingMode
public void setRoundingMode(RoundingMode roundingMode)
Sets the rounding mode for decimal divisions.- Parameters:
roundingMode- rounding mode for decimal divisions- Since:
- 2.1
-
getScale
public int getScale()
Sets the scale for division operations. The default is 64- Returns:
- the scale
- Since:
- 2.1
-
setScale
public void setScale(int scale)
Sets the scale for division operations.- Parameters:
scale- scale for division operations- Since:
- 2.1
-
subtract
public BigReal subtract(BigReal a)
- Specified by:
subtractin interfaceFieldElement<BigReal>
-
negate
public BigReal negate()
- Specified by:
negatein interfaceFieldElement<BigReal>
-
divide
public BigReal divide(BigReal a) throws MathArithmeticException
- Specified by:
dividein interfaceFieldElement<BigReal>- Throws:
MathArithmeticException- ifais zero
-
reciprocal
public BigReal reciprocal() throws MathArithmeticException
- Specified by:
reciprocalin interfaceFieldElement<BigReal>- Throws:
MathArithmeticException- ifthisis zero
-
multiply
public BigReal multiply(BigReal a)
- Specified by:
multiplyin interfaceFieldElement<BigReal>
-
multiply
public BigReal multiply(int n)
- Specified by:
multiplyin interfaceFieldElement<BigReal>
-
compareTo
public int compareTo(BigReal a)
- Specified by:
compareToin interfaceComparable<BigReal>
-
doubleValue
public double doubleValue()
Get the double value corresponding to the instance.- Returns:
- double value corresponding to the instance
-
bigDecimalValue
public BigDecimal bigDecimalValue()
Get the BigDecimal value corresponding to the instance.- Returns:
- BigDecimal value corresponding to the instance
-
-