public class Real extends java.lang.Number implements Field<Real>, java.lang.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(java.math.BigDecimal value)
Construct a
Real from a BigDecimal. |
Real(java.math.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(java.lang.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(java.lang.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.
|
java.math.BigDecimal |
toBigDecimal()
Convert this number to a
BigDecimal. |
java.lang.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.
|
public 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(java.math.BigDecimal value)
Real from a BigDecimal.value - a BigDecimalpublic Real(java.math.BigInteger value)
Real from a BigInteger.value - a BigIntegerpublic Real(java.lang.String value)
Real from a String.value - a String representation of a numberpublic java.math.BigDecimal toBigDecimal()
BigDecimal.BigDecimalpublic int intValue()
intValue in class java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic float floatValue()
floatValue in class java.lang.Numberpublic double doubleValue()
doubleValue in class java.lang.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 java.lang.Comparable<Real>public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object