org.apache.commons.math3.util

## Class Decimal64

- java.lang.Object
- - java.lang.Number
  - - org.apache.commons.math3.util.Decimal64

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable<Decimal64>, FieldElement<Decimal64>

    public class Decimal64
    extends java.lang.Number
    implements FieldElement<Decimal64>, java.lang.Comparable<Decimal64>

This class wraps a `double` value in an object. It is similar to the standard class `Double`, while also implementing the `FieldElement` interface.

Since:
  3.1
Version:
  $Id: Decimal64.java 1306177 2012-03-28 05:40:46Z celestin $
See Also:
  Serialized Form

### Field Summary

Fields
`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 Summary

Constructors
Constructor and Description
`Decimal64(double x)` Creates a new instance of this class.

### Method Summary

Methods
`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())`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### ZERO

    public static final Decimal64 ZERO

The constant value of `0d` as a `Decimal64`.

#### ONE

    public static final Decimal64 ONE

The constant value of `1d` as a `Decimal64`.

#### NEGATIVE_INFINITY

    public static final Decimal64 NEGATIVE_INFINITY

The constant value of `Double.NEGATIVE_INFINITY` as a `Decimal64`.

#### POSITIVE_INFINITY

    public static final Decimal64 POSITIVE_INFINITY

The constant value of `Double.POSITIVE_INFINITY` as a `Decimal64`.

#### NAN

    public static final Decimal64 NAN

The constant value of `Double.NaN` as a `Decimal64`.

#### serialVersionUID

    private static final long serialVersionUID

See Also:
  Constant Field Values

#### value

    private final double value

The primitive `double` value of this object.

### Constructor Detail

#### Decimal64

    public Decimal64(double x)

Creates a new instance of this class.

Parameters:
  `x` - the primitive `double` value of the object to be created

### Method Detail

#### getField

    public Field<Decimal64> getField()

Get the `Field` to which the instance belongs.

Specified by:
  `getField` in interface `FieldElement<Decimal64>`
Returns:
  `Field` to which the instance belongs

#### add

    public Decimal64 add(Decimal64 a)

Compute this + a. The current implementation strictly enforces `this.add(a).equals(new Decimal64(this.doubleValue() + a.doubleValue()))`.

Specified by:
  `add` in interface `FieldElement<Decimal64>`
Parameters:
  `a` - element to add
Returns:
  a new element representing this + a

#### subtract

    public Decimal64 subtract(Decimal64 a)

Compute this - a. The current implementation strictly enforces `this.subtract(a).equals(new Decimal64(this.doubleValue() - a.doubleValue()))`.

Specified by:
  `subtract` in interface `FieldElement<Decimal64>`
Parameters:
  `a` - element to subtract
Returns:
  a new element representing this - a

#### negate

    public Decimal64 negate()

Returns the additive inverse of `this` element. The current implementation strictly enforces `this.negate().equals(new Decimal64(-this.doubleValue()))`.

Specified by:
  `negate` in interface `FieldElement<Decimal64>`
Returns:
  the opposite of `this`.

#### multiply

    public Decimal64 multiply(Decimal64 a)

Compute this × a. The current implementation strictly enforces `this.multiply(a).equals(new Decimal64(this.doubleValue() * a.doubleValue()))`.

Specified by:
  `multiply` in interface `FieldElement<Decimal64>`
Parameters:
  `a` - element to multiply
Returns:
  a new element representing this × a

#### multiply

    public Decimal64 multiply(int n)

Compute n × this. Multiplication by an integer number is defined as the following sum
n × this = ∑i=1n this.
The current implementation strictly enforces `this.multiply(n).equals(new Decimal64(n * this.doubleValue()))`.

Specified by:
  `multiply` in interface `FieldElement<Decimal64>`
Parameters:
  `n` - Number of times `this` must be added to itself.
Returns:
  A new element representing n × this.

#### divide

    public Decimal64 divide(Decimal64 a)

Compute this ÷ a. The current implementation strictly enforces `this.divide(a).equals(new Decimal64(this.doubleValue() / a.doubleValue()))`.

Specified by:
  `divide` in interface `FieldElement<Decimal64>`
Parameters:
  `a` - element to add
Returns:
  a new element representing this ÷ a

#### reciprocal

    public Decimal64 reciprocal()

Returns the multiplicative inverse of `this` element. The current implementation strictly enforces `this.reciprocal().equals(new Decimal64(1.0 / this.doubleValue()))`.

Specified by:
  `reciprocal` in interface `FieldElement<Decimal64>`
Returns:
  the inverse of `this`.

#### byteValue

    public byte byteValue()

The current implementation performs casting to a `byte`.

Overrides:
  `byteValue` in class `java.lang.Number`

#### shortValue

    public short shortValue()

The current implementation performs casting to a `short`.

Overrides:
  `shortValue` in class `java.lang.Number`

#### intValue

    public int intValue()

The current implementation performs casting to a `int`.

Specified by:
  `intValue` in class `java.lang.Number`

#### longValue

    public long longValue()

The current implementation performs casting to a `long`.

Specified by:
  `longValue` in class `java.lang.Number`

#### floatValue

    public float floatValue()

The current implementation performs casting to a `float`.

Specified by:
  `floatValue` in class `java.lang.Number`

#### doubleValue

    public double doubleValue()

Specified by:
  `doubleValue` in class `java.lang.Number`

#### compareTo

    public int compareTo(Decimal64 o)

The current implementation returns the same value as
`new Double(this.doubleValue()).compareTo(new Double(o.doubleValue()))`

Specified by:
  `compareTo` in interface `java.lang.Comparable<Decimal64>`
See Also:
  `Double.compareTo(Double)`

#### equals

    public boolean equals(java.lang.Object obj)

Overrides:
  `equals` in class `java.lang.Object`

#### hashCode

    public int hashCode()

The current implementation returns the same value as `new Double(this.doubleValue()).hashCode()`

Overrides:
  `hashCode` in class `java.lang.Object`
See Also:
  `Double.hashCode()`

#### toString

    public java.lang.String toString()

The returned `String` is equal to `Double.toString(this.doubleValue())`

Overrides:
  `toString` in class `java.lang.Object`
See Also:
  `Double.toString(double)`

#### isInfinite

    public boolean isInfinite()

Returns `true` if `this` double precision number is infinite (`Double.POSITIVE_INFINITY` or `Double.NEGATIVE_INFINITY`).

Returns:
  `true` if `this` number is infinite

#### isNaN

    public boolean isNaN()

Returns `true` if `this` double precision number is Not-a-Number (`NaN`), false otherwise.

Returns:
  `true` if `this` is `NaN`