org.hipparchus.util

## Class Decimal64

• ### Field Summary

Fields
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 PI
The constant value of π as a Decimal64.
static Decimal64 POSITIVE_INFINITY
The constant value of Double.POSITIVE_INFINITY as a Decimal64.
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

All Methods
Modifier and Type Method and Description
Decimal64 abs()
absolute value.
Decimal64 acos()
Arc cosine operation.
Decimal64 acosh()
Inverse hyperbolic cosine operation.
Decimal64 add(Decimal64 a)
Compute this + a.
Decimal64 add(double a)
'+' operator.
Decimal64 asin()
Arc sine operation.
Decimal64 asinh()
Inverse hyperbolic sine operation.
Decimal64 atan()
Arc tangent operation.
Decimal64 atan2(Decimal64 x)
Two arguments arc tangent operation.
Decimal64 atanh()
Inverse hyperbolic tangent operation.
byte byteValue()
The current implementation performs casting to a byte.
Decimal64 cbrt()
Cubic root.
Decimal64 ceil()
Get the smallest whole number larger than instance.
int compareTo(Decimal64 o)
The current implementation returns the same value as new Double(this.doubleValue()).compareTo(new Double(o.doubleValue()))
Decimal64 copySign(Decimal64 sign)
Returns the instance with the sign of the argument.
Decimal64 copySign(double sign)
Returns the instance with the sign of the argument.
Decimal64 cos()
Cosine operation.
Decimal64 cosh()
Hyperbolic cosine operation.
Decimal64 divide(Decimal64 a)
Compute this ÷ a.
Decimal64 divide(double a)
'÷' operator.
double doubleValue()
boolean equals(Object obj)
Decimal64 exp()
Exponential.
Decimal64 expm1()
Exponential minus 1.
float floatValue()
The current implementation performs casting to a float.
Decimal64 floor()
Get the largest whole number smaller than instance.
Field<Decimal64> getField()
Get the Field to which the instance belongs.
Decimal64 getPi()
Get the Archimedes constant π.
double getReal()
Get the real value of the number.
int hashCode()
The current implementation returns the same value as new Double(this.doubleValue()).hashCode()
Decimal64 hypot(Decimal64 y)
Returns the hypotenuse of a triangle with sides this and y - sqrt(this2 +y2) avoiding intermediate overflow or underflow.
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.
boolean isZero()
Check if an element is semantically equal to zero.
Decimal64 linearCombination(Decimal64[] a, Decimal64[] b)
Compute a linear combination.
Decimal64 linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2)
Compute a linear combination.
Decimal64 linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2, Decimal64 a3, Decimal64 b3)
Compute a linear combination.
Decimal64 linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2, Decimal64 a3, Decimal64 b3, Decimal64 a4, Decimal64 b4)
Compute a linear combination.
Decimal64 linearCombination(double[] a, Decimal64[] b)
Compute a linear combination.
Decimal64 linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2)
Compute a linear combination.
Decimal64 linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2, double a3, Decimal64 b3)
Compute a linear combination.
Decimal64 linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2, double a3, Decimal64 b3, double a4, Decimal64 b4)
Compute a linear combination.
Decimal64 log()
Natural logarithm.
Decimal64 log10()
Base 10 logarithm.
Decimal64 log1p()
Shifted natural logarithm.
long longValue()
The current implementation performs casting to a long.
Decimal64 multiply(Decimal64 a)
Compute this × a.
Decimal64 multiply(double a)
'×' operator.
Decimal64 multiply(int n)
Compute n × this.
Decimal64 negate()
Returns the additive inverse of this element.
Decimal64 newInstance(double v)
Create an instance corresponding to a constant real value.
Decimal64 pow(Decimal64 e)
Power operation.
Decimal64 pow(double p)
Power operation.
Decimal64 pow(int n)
Integer power operation.
Decimal64 reciprocal()
Returns the multiplicative inverse of this element.
Decimal64 remainder(Decimal64 a)
IEEE remainder operator.
Decimal64 remainder(double a)
IEEE remainder operator.
Decimal64 rint()
Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers.
Decimal64 rootN(int n)
Nth root.
Decimal64 scalb(int n)
Multiply the instance by a power of 2.
short shortValue()
The current implementation performs casting to a short.
Decimal64 sign()
Compute the sign of the instance.
Decimal64 sin()
Sine operation.
FieldSinCos<Decimal64> sinCos()
Combined Sine and Cosine operation.
Decimal64 sinh()
Hyperbolic sine operation.
FieldSinhCosh<Decimal64> sinhCosh()
Combined hyperbolic sine and sosine operation.
Decimal64 sqrt()
Square root.
Decimal64 subtract(Decimal64 a)
Compute this - a.
Decimal64 subtract(double a)
'-' operator.
Decimal64 tan()
Tangent operation.
Decimal64 tanh()
Hyperbolic tangent operation.
Decimal64 toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP
Decimal64 toRadians()
Convert degrees to radians, with error of less than 0.5 ULP
String toString()
The returned String is equal to Double.toString(this.doubleValue())
Decimal64 ulp()
Compute least significant bit (Unit in Last Position) for a number.
• ### Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait
• ### Methods inherited from interface org.hipparchus.CalculusFieldElement

getExponent, isFinite, norm, round
• ### 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.
• #### PI

public static final Decimal64 PI
The constant value of π 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.
• ### 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

• #### newInstance

public Decimal64 newInstance(double v)
Create an instance corresponding to a constant real value.
Specified by:
newInstance in interface CalculusFieldElement<Decimal64>
Parameters:
v - constant real value
Returns:
instance corresponding to a constant real value
• #### 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

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 divide by
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 CalculusFieldElement<Decimal64>
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 Number
• #### shortValue

public short shortValue()
The current implementation performs casting to a short.
Overrides:
shortValue in class Number
• #### intValue

public int intValue()
The current implementation performs casting to a int.
Specified by:
intValue in class Number
• #### longValue

public long longValue()
The current implementation performs casting to a long.
Specified by:
longValue in class Number
• #### floatValue

public float floatValue()
The current implementation performs casting to a float.
Specified by:
floatValue in class Number
• #### doubleValue

public double doubleValue()
Specified by:
doubleValue in class 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 Comparable<Decimal64>
Double.compareTo(Double)
• #### equals

public boolean equals(Object obj)
Overrides:
equals in class Object
• #### isZero

public boolean isZero()
Check if an element is semantically equal to zero.

The default implementation simply calls equals(getField().getZero()). However, this may need to be overridden in some cases as due to compatibility with hashCode() some classes implements equals(Object) in such a way that -0.0 and +0.0 are different, which may be a problem. It prevents for example identifying a diagonal element is zero and should be avoided when doing partial pivoting in LU decomposition.

This implementation considers +0.0 and -0.0 to be equal.

Specified by:
isZero in interface FieldElement<Decimal64>
Returns:
true if the element is semantically equal to zero
Since:
1.8
• #### hashCode

public int hashCode()
The current implementation returns the same value as new Double(this.doubleValue()).hashCode()
Overrides:
hashCode in class Object
Double.hashCode()
• #### toString

public String toString()
The returned String is equal to Double.toString(this.doubleValue())
Overrides:
toString in class Object
Double.toString(double)
• #### isInfinite

public boolean isInfinite()
Returns true if this double precision number is infinite (Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY).
Specified by:
isInfinite in interface CalculusFieldElement<Decimal64>
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.
Specified by:
isNaN in interface CalculusFieldElement<Decimal64>
Returns:
true if this is NaN
• #### getReal

public double getReal()
Get the real value of the number.
Specified by:
getReal in interface FieldElement<Decimal64>
Returns:
real value

public Decimal64 add(double a)
'+' operator.
Specified by:
add in interface CalculusFieldElement<Decimal64>
Parameters:
a - right hand side parameter of the operator
Returns:
this+a
• #### subtract

public Decimal64 subtract(double a)
'-' operator.
Specified by:
subtract in interface CalculusFieldElement<Decimal64>
Parameters:
a - right hand side parameter of the operator
Returns:
this-a
• #### multiply

public Decimal64 multiply(double a)
'×' operator.
Specified by:
multiply in interface CalculusFieldElement<Decimal64>
Parameters:
a - right hand side parameter of the operator
Returns:
this×a
• #### divide

public Decimal64 divide(double a)
'÷' operator.
Specified by:
divide in interface CalculusFieldElement<Decimal64>
Parameters:
a - right hand side parameter of the operator
Returns:
this÷a
• #### remainder

public Decimal64 remainder(double a)
IEEE remainder operator.
Specified by:
remainder in interface CalculusFieldElement<Decimal64>
Parameters:
a - right hand side parameter of the operator
Returns:
this - n × a where n is the closest integer to this/a
• #### remainder

public Decimal64 remainder(Decimal64 a)
IEEE remainder operator.
Specified by:
remainder in interface CalculusFieldElement<Decimal64>
Parameters:
a - right hand side parameter of the operator
Returns:
this - n × a where n is the closest integer to this/a
• #### abs

public Decimal64 abs()
absolute value.

Just another name for CalculusFieldElement.norm()

Specified by:
abs in interface CalculusFieldElement<Decimal64>
Returns:
abs(this)
• #### ceil

public Decimal64 ceil()
Get the smallest whole number larger than instance.
Specified by:
ceil in interface CalculusFieldElement<Decimal64>
Returns:
ceil(this)
• #### floor

public Decimal64 floor()
Get the largest whole number smaller than instance.
Specified by:
floor in interface CalculusFieldElement<Decimal64>
Returns:
floor(this)
• #### rint

public Decimal64 rint()
Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers.
Specified by:
rint in interface CalculusFieldElement<Decimal64>
Returns:
a double number r such that r is an integer r - 0.5 ≤ this ≤ r + 0.5
• #### sign

public Decimal64 sign()
Compute the sign of the instance. The sign is -1 for negative numbers, +1 for positive numbers and 0 otherwise, for Complex number, it is extended on the unit circle (equivalent to z/|z|, with special handling for 0 and NaN)
Specified by:
sign in interface CalculusFieldElement<Decimal64>
Returns:
-1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a
• #### copySign

public Decimal64 copySign(Decimal64 sign)
Returns the instance with the sign of the argument. A NaN sign argument is treated as positive.
Specified by:
copySign in interface CalculusFieldElement<Decimal64>
Parameters:
sign - the sign for the returned value
Returns:
the instance with the same sign as the sign argument
• #### copySign

public Decimal64 copySign(double sign)
Returns the instance with the sign of the argument. A NaN sign argument is treated as positive.
Specified by:
copySign in interface CalculusFieldElement<Decimal64>
Parameters:
sign - the sign for the returned value
Returns:
the instance with the same sign as the sign argument
• #### scalb

public Decimal64 scalb(int n)
Multiply the instance by a power of 2.
Specified by:
scalb in interface CalculusFieldElement<Decimal64>
Parameters:
n - power of 2
Returns:
this × 2n
• #### ulp

public Decimal64 ulp()
Compute least significant bit (Unit in Last Position) for a number.
Specified by:
ulp in interface CalculusFieldElement<Decimal64>
Returns:
ulp(this)
• #### hypot

public Decimal64 hypot(Decimal64 y)
Returns the hypotenuse of a triangle with sides this and y - sqrt(this2 +y2) avoiding intermediate overflow or underflow.
• If either argument is infinite, then the result is positive infinity.
• else, if either argument is NaN then the result is NaN.
Specified by:
hypot in interface CalculusFieldElement<Decimal64>
Parameters:
y - a value
Returns:
sqrt(this2 +y2)
• #### sqrt

public Decimal64 sqrt()
Square root.
Specified by:
sqrt in interface CalculusFieldElement<Decimal64>
Returns:
square root of the instance
• #### cbrt

public Decimal64 cbrt()
Cubic root.
Specified by:
cbrt in interface CalculusFieldElement<Decimal64>
Returns:
cubic root of the instance
• #### rootN

public Decimal64 rootN(int n)
Nth root.
Specified by:
rootN in interface CalculusFieldElement<Decimal64>
Parameters:
n - order of the root
Returns:
nth root of the instance
• #### pow

public Decimal64 pow(double p)
Power operation.
Specified by:
pow in interface CalculusFieldElement<Decimal64>
Parameters:
p - power to apply
Returns:
thisp
• #### pow

public Decimal64 pow(int n)
Integer power operation.
Specified by:
pow in interface CalculusFieldElement<Decimal64>
Parameters:
n - power to apply
Returns:
thisn
• #### pow

public Decimal64 pow(Decimal64 e)
Power operation.
Specified by:
pow in interface CalculusFieldElement<Decimal64>
Parameters:
e - exponent
Returns:
thise
• #### exp

public Decimal64 exp()
Exponential.
Specified by:
exp in interface CalculusFieldElement<Decimal64>
Returns:
exponential of the instance
• #### expm1

public Decimal64 expm1()
Exponential minus 1.
Specified by:
expm1 in interface CalculusFieldElement<Decimal64>
Returns:
exponential minus one of the instance
• #### log

public Decimal64 log()
Natural logarithm.
Specified by:
log in interface CalculusFieldElement<Decimal64>
Returns:
logarithm of the instance
• #### log1p

public Decimal64 log1p()
Shifted natural logarithm.
Specified by:
log1p in interface CalculusFieldElement<Decimal64>
Returns:
logarithm of one plus the instance
• #### log10

public Decimal64 log10()
Base 10 logarithm.
Specified by:
log10 in interface CalculusFieldElement<Decimal64>
Returns:
base 10 logarithm of the instance
• #### cos

public Decimal64 cos()
Cosine operation.
Specified by:
cos in interface CalculusFieldElement<Decimal64>
Returns:
cos(this)
• #### sin

public Decimal64 sin()
Sine operation.
Specified by:
sin in interface CalculusFieldElement<Decimal64>
Returns:
sin(this)
• #### sinCos

public FieldSinCos<Decimal64> sinCos()
Combined Sine and Cosine operation.
Specified by:
sinCos in interface CalculusFieldElement<Decimal64>
Returns:
[sin(this), cos(this)]
• #### tan

public Decimal64 tan()
Tangent operation.
Specified by:
tan in interface CalculusFieldElement<Decimal64>
Returns:
tan(this)
• #### acos

public Decimal64 acos()
Arc cosine operation.
Specified by:
acos in interface CalculusFieldElement<Decimal64>
Returns:
acos(this)
• #### asin

public Decimal64 asin()
Arc sine operation.
Specified by:
asin in interface CalculusFieldElement<Decimal64>
Returns:
asin(this)
• #### atan

public Decimal64 atan()
Arc tangent operation.
Specified by:
atan in interface CalculusFieldElement<Decimal64>
Returns:
atan(this)
• #### atan2

public Decimal64 atan2(Decimal64 x)
Two arguments arc tangent operation.

Beware of the order or arguments! As this is based on a two-arguments functions, in order to be consistent with arguments order, the instance is the first argument and the single provided argument is the second argument. In order to be consistent with programming languages atan2, this method computes atan2(this, x), i.e. the instance represents the y argument and the x argument is the one passed as a single argument. This may seem confusing especially for users of Wolfram alpha, as this site is not consistent with programming languages atan2 two-arguments arc tangent and puts x as its first argument.

Specified by:
atan2 in interface CalculusFieldElement<Decimal64>
Parameters:
x - second argument of the arc tangent
Returns:
atan2(this, x)
• #### cosh

public Decimal64 cosh()
Hyperbolic cosine operation.
Specified by:
cosh in interface CalculusFieldElement<Decimal64>
Returns:
cosh(this)
• #### sinh

public Decimal64 sinh()
Hyperbolic sine operation.
Specified by:
sinh in interface CalculusFieldElement<Decimal64>
Returns:
sinh(this)
• #### sinhCosh

public FieldSinhCosh<Decimal64> sinhCosh()
Combined hyperbolic sine and sosine operation.
Specified by:
sinhCosh in interface CalculusFieldElement<Decimal64>
Returns:
[sinh(this), cosh(this)]
• #### tanh

public Decimal64 tanh()
Hyperbolic tangent operation.
Specified by:
tanh in interface CalculusFieldElement<Decimal64>
Returns:
tanh(this)
• #### acosh

public Decimal64 acosh()
Inverse hyperbolic cosine operation.
Specified by:
acosh in interface CalculusFieldElement<Decimal64>
Returns:
acosh(this)
• #### asinh

public Decimal64 asinh()
Inverse hyperbolic sine operation.
Specified by:
asinh in interface CalculusFieldElement<Decimal64>
Returns:
asin(this)
• #### atanh

public Decimal64 atanh()
Inverse hyperbolic tangent operation.
Specified by:
atanh in interface CalculusFieldElement<Decimal64>
Returns:
atanh(this)
• #### toDegrees

public Decimal64 toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP
Specified by:
toDegrees in interface CalculusFieldElement<Decimal64>
Returns:
instance converted into degrees

public Decimal64 toRadians()
Convert degrees to radians, with error of less than 0.5 ULP
Specified by:
toRadians in interface CalculusFieldElement<Decimal64>
Returns:
• #### linearCombination

public Decimal64 linearCombination(Decimal64[] a,
Decimal64[] b)
throws MathIllegalArgumentException
Compute a linear combination.
Specified by:
linearCombination in interface CalculusFieldElement<Decimal64>
Parameters:
a - Factors.
b - Factors.
Returns:
Σi ai bi.
Throws:
MathIllegalArgumentException - if arrays dimensions don't match
• #### linearCombination

public Decimal64 linearCombination(double[] a,
Decimal64[] b)
throws MathIllegalArgumentException
Compute a linear combination.
Specified by:
linearCombination in interface CalculusFieldElement<Decimal64>
Parameters:
a - Factors.
b - Factors.
Returns:
Σi ai bi.
Throws:
MathIllegalArgumentException - if arrays dimensions don't match
• #### getPi

public Decimal64 getPi()
Get the Archimedes constant π.

Archimedes constant is the ratio of a circle's circumference to its diameter.

Specified by:
getPi in interface CalculusFieldElement<Decimal64>
Returns:
Archimedes constant π