public class BigReal extends java.lang.Object implements FieldElement<BigReal>, java.lang.Comparable<BigReal>, java.io.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(java.math.BigDecimal val)
Build an instance from a BigDecimal.
|
BigReal(java.math.BigInteger val)
Build an instance from a BigInteger.
|
BigReal(java.math.BigInteger unscaledVal,
int scale)
Build an instance from an unscaled BigInteger.
|
BigReal(java.math.BigInteger unscaledVal,
int scale,
java.math.MathContext mc)
Build an instance from an unscaled BigInteger.
|
BigReal(java.math.BigInteger val,
java.math.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,
java.math.MathContext mc)
Build an instance from a characters representation.
|
BigReal(char[] in,
java.math.MathContext mc)
Build an instance from a characters representation.
|
BigReal(double val)
Build an instance from a double.
|
BigReal(double val,
java.math.MathContext mc)
Build an instance from a double.
|
BigReal(int val)
Build an instance from an int.
|
BigReal(int val,
java.math.MathContext mc)
Build an instance from an int.
|
BigReal(long val)
Build an instance from a long.
|
BigReal(long val,
java.math.MathContext mc)
Build an instance from a long.
|
BigReal(java.lang.String val)
Build an instance from a String representation.
|
BigReal(java.lang.String val,
java.math.MathContext mc)
Build an instance from a String representation.
|
Modifier and Type | Method and Description |
---|---|
BigReal |
add(BigReal a)
Compute this + a.
|
java.math.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(java.lang.Object other) |
Field<BigReal> |
getField()
Get the
Field to which the instance belongs. |
java.math.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.
|
void |
setRoundingMode(java.math.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.
|
public static final BigReal ZERO
public static final BigReal ONE
public BigReal(java.math.BigDecimal val)
val
- value of the instancepublic BigReal(java.math.BigInteger val)
val
- value of the instancepublic BigReal(java.math.BigInteger unscaledVal, int scale)
unscaledVal
- unscaled valuescale
- scale to usepublic BigReal(java.math.BigInteger unscaledVal, int scale, java.math.MathContext mc)
unscaledVal
- unscaled valuescale
- scale to usemc
- to usedpublic BigReal(java.math.BigInteger val, java.math.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, java.math.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, java.math.MathContext mc)
in
- character representation of the valuemc
- context to usepublic BigReal(double val)
val
- value of the instancepublic BigReal(double val, java.math.MathContext mc)
val
- value of the instancemc
- context to usepublic BigReal(int val)
val
- value of the instancepublic BigReal(int val, java.math.MathContext mc)
val
- value of the instancemc
- context to usepublic BigReal(long val)
val
- value of the instancepublic BigReal(long val, java.math.MathContext mc)
val
- value of the instancemc
- context to usepublic BigReal(java.lang.String val)
val
- character representation of the valuepublic BigReal(java.lang.String val, java.math.MathContext mc)
val
- character representation of the valuemc
- context to usepublic java.math.RoundingMode getRoundingMode()
RoundingMode.HALF_UP
public void setRoundingMode(java.math.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 addpublic BigReal subtract(BigReal a)
subtract
in interface FieldElement<BigReal>
a
- element to subtractpublic BigReal divide(BigReal a) throws java.lang.ArithmeticException
divide
in interface FieldElement<BigReal>
a
- element to addjava.lang.ArithmeticException
- if a is the zero of the
additive operation (i.e. additive identity)public BigReal multiply(BigReal a)
multiply
in interface FieldElement<BigReal>
a
- element to multiplypublic int compareTo(BigReal a)
compareTo
in interface java.lang.Comparable<BigReal>
public double doubleValue()
public java.math.BigDecimal bigDecimalValue()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Copyright © 2010 - 2020 Adobe. All Rights Reserved