public class BigReal extends Object implements FieldElement<BigReal>, Comparable<BigReal>, Serializable
This class is a simple wrapper around the standard BigDecimal
in order to implement the
FieldElement
interface.
Modifier and Type | Field and Description |
---|---|
static BigReal |
ONE
A big real representing 1.
|
static BigReal |
ZERO
A big real representing 0.
|
Constructor and Description |
---|
BigReal(BigDecimal val)
Build an instance from a BigDecimal.
|
BigReal(BigInteger val)
Build an instance from a BigInteger.
|
BigReal(BigInteger unscaledVal,
int scaleIn)
Build an instance from an unscaled BigInteger.
|
BigReal(BigInteger unscaledVal,
int scaleIn,
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.
|
Modifier and Type | Method and Description |
---|---|
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 roundingModeIn)
Sets the rounding mode for decimal divisions.
|
void |
setScale(int scaleIn)
Sets the scale for division operations.
|
BigReal |
subtract(BigReal a)
Compute this - a.
|
public static final BigReal ZERO
public static final BigReal ONE
public BigReal(BigDecimal val)
val
- value of the instancepublic BigReal(BigInteger val)
val
- value of the instancepublic BigReal(BigInteger unscaledVal, int scaleIn)
unscaledVal
- unscaled valuescaleIn
- scale to usepublic BigReal(BigInteger unscaledVal, int scaleIn, MathContext mc)
unscaledVal
- unscaled valuescaleIn
- 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 usepublic RoundingMode getRoundingMode()
RoundingMode.HALF_UP
public void setRoundingMode(RoundingMode roundingModeIn)
roundingModeIn
- rounding mode for decimal divisionspublic int getScale()
public void setScale(int scaleIn)
scaleIn
- scale for division operationspublic BigReal add(BigReal a)
add
in interface FieldElement<BigReal>
a
- element to addpublic BigReal subtract(BigReal a)
subtract
in interface FieldElement<BigReal>
a
- element to subtractpublic BigReal negate()
this
element.negate
in interface FieldElement<BigReal>
this
.public BigReal divide(BigReal a)
divide
in interface FieldElement<BigReal>
a
- element to addMathArithmeticException
- if a
is zeropublic BigReal reciprocal()
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 multiplypublic 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()
Copyright © 2019 CNES. All rights reserved.