org.apache.commons.math3.util
public class Decimal64 extends java.lang.Number implements FieldElement<Decimal64>, java.lang.Comparable<Decimal64>
double
value in an object. It is similar to the
standard class Double
, while also implementing the
FieldElement
interface.Modifier and Type | Field and Description |
---|---|
static Decimal64 |
NAN
The constant value of
Double.NaN as a Decimal64 . |
static Decimal64 |
NEGATIVE_INFINITY
The constant value of
Double.NEGATIVE_INFINITY as a
Decimal64 . |
static Decimal64 |
ONE
The constant value of
1d as a Decimal64 . |
static Decimal64 |
POSITIVE_INFINITY
The constant value of
Double.POSITIVE_INFINITY as a
Decimal64 . |
private static long |
serialVersionUID |
private double |
value
The primitive
double value of this object. |
static Decimal64 |
ZERO
The constant value of
0d as a Decimal64 . |
Constructor and Description |
---|
Decimal64(double x)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
Decimal64 |
add(Decimal64 a)
Compute this + a.
|
byte |
byteValue()
The current implementation performs casting to a
byte . |
int |
compareTo(Decimal64 o)
The current implementation returns the same value as
new Double(this.doubleValue()).compareTo(new
Double(o.doubleValue())) |
Decimal64 |
divide(Decimal64 a)
Compute this ÷ a.
|
double |
doubleValue() |
boolean |
equals(java.lang.Object obj) |
float |
floatValue()
The current implementation performs casting to a
float . |
Field<Decimal64> |
getField()
Get the
Field to which the instance belongs. |
int |
hashCode()
The current implementation returns the same value as
new Double(this.doubleValue()).hashCode() |
int |
intValue()
The current implementation performs casting to a
int . |
boolean |
isInfinite()
Returns
true if this double precision number is infinite
(Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY ). |
boolean |
isNaN()
Returns
true if this double precision number is
Not-a-Number (NaN ), false otherwise. |
long |
longValue()
The current implementation performs casting to a
long . |
Decimal64 |
multiply(Decimal64 a)
Compute this × a.
|
Decimal64 |
multiply(int n)
Compute n × this.
|
Decimal64 |
negate()
Returns the additive inverse of
this element. |
Decimal64 |
reciprocal()
Returns the multiplicative inverse of
this element. |
short |
shortValue()
The current implementation performs casting to a
short . |
Decimal64 |
subtract(Decimal64 a)
Compute this - a.
|
java.lang.String |
toString()
The returned
String is equal to
Double.toString(this.doubleValue()) |
public static final Decimal64 ZERO
0d
as a Decimal64
.public static final Decimal64 ONE
1d
as a Decimal64
.public static final Decimal64 NEGATIVE_INFINITY
Double.NEGATIVE_INFINITY
as a
Decimal64
.public static final Decimal64 POSITIVE_INFINITY
Double.POSITIVE_INFINITY
as a
Decimal64
.public static final Decimal64 NAN
Double.NaN
as a Decimal64
.private static final long serialVersionUID
private final double value
double
value of this object.public Decimal64(double x)
x
- the primitive double
value of the object to be createdpublic Field<Decimal64> getField()
Field
to which the instance belongs.getField
in interface FieldElement<Decimal64>
Field
to which the instance belongspublic Decimal64 add(Decimal64 a)
this.add(a).equals(new Decimal64(this.doubleValue()
+ a.doubleValue()))
.add
in interface FieldElement<Decimal64>
a
- element to addpublic Decimal64 subtract(Decimal64 a)
this.subtract(a).equals(new Decimal64(this.doubleValue()
- a.doubleValue()))
.subtract
in interface FieldElement<Decimal64>
a
- element to subtractpublic Decimal64 negate()
this
element.
The current implementation strictly enforces
this.negate().equals(new Decimal64(-this.doubleValue()))
.negate
in interface FieldElement<Decimal64>
this
.public Decimal64 multiply(Decimal64 a)
this.multiply(a).equals(new Decimal64(this.doubleValue()
* a.doubleValue()))
.multiply
in interface FieldElement<Decimal64>
a
- element to multiplypublic Decimal64 multiply(int n)
this.multiply(n).equals(new Decimal64(n * this.doubleValue()))
.multiply
in interface FieldElement<Decimal64>
n
- Number of times this
must be added to itself.public Decimal64 divide(Decimal64 a)
this.divide(a).equals(new Decimal64(this.doubleValue()
/ a.doubleValue()))
.divide
in interface FieldElement<Decimal64>
a
- element to addpublic Decimal64 reciprocal()
this
element.
The current implementation strictly enforces
this.reciprocal().equals(new Decimal64(1.0
/ this.doubleValue()))
.reciprocal
in interface FieldElement<Decimal64>
this
.public byte byteValue()
byte
.byteValue
in class java.lang.Number
public short shortValue()
short
.shortValue
in class java.lang.Number
public int intValue()
int
.intValue
in class java.lang.Number
public long longValue()
long
.longValue
in class java.lang.Number
public float floatValue()
float
.floatValue
in class java.lang.Number
public double doubleValue()
doubleValue
in class java.lang.Number
public int compareTo(Decimal64 o)
new Double(this.doubleValue()).compareTo(new
Double(o.doubleValue()))
compareTo
in interface java.lang.Comparable<Decimal64>
Double.compareTo(Double)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
new Double(this.doubleValue()).hashCode()
hashCode
in class java.lang.Object
Double.hashCode()
public java.lang.String toString()
String
is equal to
Double.toString(this.doubleValue())
toString
in class java.lang.Object
Double.toString(double)
public boolean isInfinite()
true
if this
double precision number is infinite
(Double.POSITIVE_INFINITY
or Double.NEGATIVE_INFINITY
).true
if this
number is infinitepublic boolean isNaN()
true
if this
double precision number is
Not-a-Number (NaN
), false otherwise.true
if this
is NaN
Copyright (c) 2003-2013 Apache Software Foundation