public class Real extends Number implements Field<Real>, Comparable<Real>
BigDecimal and implements the Field interface.
This class is immutable.Field.InverseNonExistent| Modifier and Type | Field and Description |
|---|---|
static Real |
ONE
a number representing 1
|
static Real |
ZERO
a number representing 0
|
| Constructor and Description |
|---|
Real(BigDecimal value)
Construct a
Real from a BigDecimal. |
Real(BigInteger value)
Construct a
Real from a BigInteger. |
Real(double value)
Construct a
Real from a double. |
Real(long value)
Construct a
Real from an integer. |
Real(String value)
Construct a
Real from a String. |
| Modifier and Type | Method and Description |
|---|---|
Real |
add(Real that)
+ : G × G → G
|
int |
compareTo(Real that) |
Real |
divide(Real that)
/ : F × F → F
That is the same as
this.multiply(that.inverse()) |
Real |
divide(Real that,
int scale)
/ : R × R → R
Divide this number by another one.
|
double |
doubleValue() |
boolean |
equals(Object obj) |
float |
floatValue() |
int |
hashCode() |
int |
intValue() |
Real |
inverse()
For each a in F, there exists an element b in F such that
a × b = b × a = 1.
|
long |
longValue() |
Real |
minus(Real that)
- : G × G → G
The operation "-" is not in the definition of of an additive group but can be deduced.
|
Real |
multiply(Real that)
× : G × G → G
|
Real |
ONE()
The multiplicative element 1 in the group such that for any elements a in the group,
the equation 1 × a = a × 1 = a holds.
|
Real |
opposite()
For each a in G, there exists an element b in G such that
a + b = b + a = 0.
|
BigDecimal |
toBigDecimal()
Convert this number to a
BigDecimal. |
String |
toString() |
Real |
ZERO()
The additive element 0 in the group, such that for all elements a in the group,
the equation 0 + a = a + 0 = a holds.
|
byteValue, shortValuepublic static final Real ZERO
public static final Real ONE
public Real(double value)
Real from a double.value - a doublepublic Real(long value)
Real from an integer.value - an integerpublic Real(BigDecimal value)
Real from a BigDecimal.value - a BigDecimalpublic Real(BigInteger value)
Real from a BigInteger.value - a BigIntegerpublic Real(String value)
Real from a String.value - a String representation of a numberpublic BigDecimal toBigDecimal()
BigDecimal.BigDecimalpublic float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Numberpublic Real add(Real that)
AbelianGroupadd in interface AbelianGroup<Real>that - the object to be addedpublic Real minus(Real that)
AbelianGroupthis.add(that.opposite()).minus in interface AbelianGroup<Real>that - the object to be subtracted (subtrahend)public Real opposite()
AbelianGroupthis.add(this.opposite()) == this.ZEROopposite in interface AbelianGroup<Real>public Real divide(Real that)
Fieldthis.multiply(that.inverse())public Real divide(Real that, int scale)
scale.that - another non-zero real numberscale - rounding scale as in BigDecimalpublic Real inverse() throws Field.InverseNonExistent
Fieldthis.multiply(this.inverse()) == this.ONEinverse in interface Field<Real>Field.InverseNonExistent - if the inverse does not existpublic Real ZERO()
AbelianGroupZERO in interface AbelianGroup<Real>public Real ONE()
Monoidpublic int compareTo(Real that)
compareTo in interface Comparable<Real>Copyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.