|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.util.BigReal
public class BigReal
Arbitrary precision decimal number.
This class is a simple wrapper around the standard BigDecimal
in order to implement the FieldElement
interface.
Field Summary | |
---|---|
static BigReal |
ONE
A big real representing 1. |
static BigReal |
ZERO
A big real representing 0. |
Constructor Summary | |
---|---|
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. |
|
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. |
Method Summary | |
---|---|
BigReal |
add(BigReal a)
Compute this + a. |
BigDecimal |
bigDecimalValue()
Get the BigDecimal value corresponding to the instance. |
int |
compareTo(BigReal a)
|
BigReal |
divide(BigReal a)
Compute this ÷ a. |
double |
doubleValue()
Get the double value corresponding to the instance. |
boolean |
equals(Object other)
|
Field<BigReal> |
getField()
Get the Field to which the instance belongs. |
RoundingMode |
getRoundingMode()
Gets the rounding mode for division operations The default is RoundingMode.HALF_UP |
int |
getScale()
Sets the scale for division operations. |
int |
hashCode()
|
BigReal |
multiply(BigReal a)
Compute this × a. |
BigReal |
multiply(int n)
Compute n × this. |
BigReal |
negate()
Returns the additive inverse of this element. |
BigReal |
reciprocal()
Returns the multiplicative inverse of this element. |
void |
setRoundingMode(RoundingMode roundingMode)
Sets the rounding mode for decimal divisions. |
void |
setScale(int scale)
Sets the scale for division operations. |
BigReal |
subtract(BigReal a)
Compute this - a. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final BigReal ZERO
public static final BigReal ONE
Constructor Detail |
---|
public BigReal(BigDecimal val)
val
- value of the instancepublic BigReal(BigInteger val)
val
- value of the instancepublic BigReal(BigInteger unscaledVal, int scale)
unscaledVal
- unscaled valuescale
- scale to usepublic BigReal(BigInteger unscaledVal, int scale, MathContext mc)
unscaledVal
- unscaled valuescale
- scale to usemc
- to usedpublic BigReal(BigInteger val, MathContext mc)
val
- value of the instancemc
- context to usepublic BigReal(char[] in)
in
- character representation of the valuepublic BigReal(char[] in, int offset, int len)
in
- character representation of the valueoffset
- offset of the first character to analyzelen
- length of the array slice to analyzepublic BigReal(char[] in, int offset, int len, MathContext mc)
in
- character representation of the valueoffset
- offset of the first character to analyzelen
- length of the array slice to analyzemc
- context to usepublic BigReal(char[] in, MathContext mc)
in
- character representation of the valuemc
- context to usepublic BigReal(double val)
val
- value of the instancepublic BigReal(double val, MathContext mc)
val
- value of the instancemc
- context to usepublic BigReal(int val)
val
- value of the instancepublic BigReal(int val, MathContext mc)
val
- value of the instancemc
- context to usepublic BigReal(long val)
val
- value of the instancepublic BigReal(long val, MathContext mc)
val
- value of the instancemc
- context to usepublic BigReal(String val)
val
- character representation of the valuepublic BigReal(String val, MathContext mc)
val
- character representation of the valuemc
- context to useMethod Detail |
---|
public RoundingMode getRoundingMode()
RoundingMode.HALF_UP
public void setRoundingMode(RoundingMode roundingMode)
roundingMode
- rounding mode for decimal divisionspublic int getScale()
public void setScale(int scale)
scale
- scale for division operationspublic BigReal add(BigReal a)
add
in interface FieldElement<BigReal>
a
- element to add
public BigReal subtract(BigReal a)
subtract
in interface FieldElement<BigReal>
a
- element to subtract
public BigReal negate()
this
element.
negate
in interface FieldElement<BigReal>
this
.public BigReal divide(BigReal a) throws MathArithmeticException
divide
in interface FieldElement<BigReal>
a
- element to add
MathArithmeticException
- if a
is zeropublic BigReal reciprocal() throws MathArithmeticException
this
element.
reciprocal
in interface FieldElement<BigReal>
this
.
MathArithmeticException
- if this
is zeropublic BigReal multiply(BigReal a)
multiply
in interface FieldElement<BigReal>
a
- element to multiply
public BigReal multiply(int n)
multiply
in interface FieldElement<BigReal>
n
- Number of times this
must be added to itself.
public int compareTo(BigReal a)
compareTo
in interface Comparable<BigReal>
public double doubleValue()
public BigDecimal bigDecimalValue()
public boolean equals(Object other)
equals
in class Object
public int hashCode()
hashCode
in class Object
public Field<BigReal> getField()
Field
to which the instance belongs.
getField
in interface FieldElement<BigReal>
Field
to which the instance belongs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |