Package org.hipparchus.util
Class Decimal64
- java.lang.Object
-
- java.lang.Number
-
- org.hipparchus.util.Decimal64
-
- All Implemented Interfaces:
Serializable,Comparable<Decimal64>,FieldElement<Decimal64>,RealFieldElement<Decimal64>
public class Decimal64 extends Number implements RealFieldElement<Decimal64>, Comparable<Decimal64>
This class wraps adoublevalue in an object. It is similar to the standard classDouble, while also implementing theRealFieldElementinterface.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Decimal64NANThe constant value ofDouble.NaNas aDecimal64.static Decimal64NEGATIVE_INFINITYThe constant value ofDouble.NEGATIVE_INFINITYas aDecimal64.static Decimal64ONEThe constant value of1das aDecimal64.static Decimal64POSITIVE_INFINITYThe constant value ofDouble.POSITIVE_INFINITYas aDecimal64.static Decimal64ZEROThe constant value of0das aDecimal64.
-
Constructor Summary
Constructors Constructor Description Decimal64(double x)Creates a new instance of this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Decimal64abs()absolute value.Decimal64acos()Arc cosine operation.Decimal64acosh()Inverse hyperbolic cosine operation.Decimal64add(double a)'+' operator.Decimal64add(Decimal64 a)Compute this + a.Decimal64asin()Arc sine operation.Decimal64asinh()Inverse hyperbolic sine operation.Decimal64atan()Arc tangent operation.Decimal64atan2(Decimal64 x)Two arguments arc tangent operation.Decimal64atanh()Inverse hyperbolic tangent operation.bytebyteValue()The current implementation performs casting to abyte.Decimal64cbrt()Cubic root.Decimal64ceil()Get the smallest whole number larger than instance.intcompareTo(Decimal64 o)The current implementation returns the same value asnew Double(this.doubleValue()).compareTo(new Double(o.doubleValue()))Decimal64copySign(double sign)Returns the instance with the sign of the argument.Decimal64copySign(Decimal64 sign)Returns the instance with the sign of the argument.Decimal64cos()Cosine operation.Decimal64cosh()Hyperbolic cosine operation.Decimal64divide(double a)'÷' operator.Decimal64divide(Decimal64 a)Compute this ÷ a.doubledoubleValue()booleanequals(Object obj)Decimal64exp()Exponential.Decimal64expm1()Exponential minus 1.floatfloatValue()The current implementation performs casting to afloat.Decimal64floor()Get the largest whole number smaller than instance.Field<Decimal64>getField()Get theFieldto which the instance belongs.doublegetReal()Get the real value of the number.inthashCode()The current implementation returns the same value asnew Double(this.doubleValue()).hashCode()Decimal64hypot(Decimal64 y)Returns the hypotenuse of a triangle with sidesthisandy- sqrt(this2 +y2) avoiding intermediate overflow or underflow.intintValue()The current implementation performs casting to aint.booleanisInfinite()Returnstrueifthisdouble precision number is infinite (Double.POSITIVE_INFINITYorDouble.NEGATIVE_INFINITY).booleanisNaN()Returnstrueifthisdouble precision number is Not-a-Number (NaN), false otherwise.Decimal64linearCombination(double[] a, Decimal64[] b)Compute a linear combination.Decimal64linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2)Compute a linear combination.Decimal64linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2, double a3, Decimal64 b3)Compute a linear combination.Decimal64linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2, double a3, Decimal64 b3, double a4, Decimal64 b4)Compute a linear combination.Decimal64linearCombination(Decimal64[] a, Decimal64[] b)Compute a linear combination.Decimal64linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2)Compute a linear combination.Decimal64linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2, Decimal64 a3, Decimal64 b3)Compute a linear combination.Decimal64linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2, Decimal64 a3, Decimal64 b3, Decimal64 a4, Decimal64 b4)Compute a linear combination.Decimal64log()Natural logarithm.Decimal64log10()Base 10 logarithm.Decimal64log1p()Shifted natural logarithm.longlongValue()The current implementation performs casting to along.Decimal64multiply(double a)'×' operator.Decimal64multiply(int n)Compute n × this.Decimal64multiply(Decimal64 a)Compute this × a.Decimal64negate()Returns the additive inverse ofthiselement.Decimal64pow(double p)Power operation.Decimal64pow(int n)Integer power operation.Decimal64pow(Decimal64 e)Power operation.Decimal64reciprocal()Returns the multiplicative inverse ofthiselement.Decimal64remainder(double a)IEEE remainder operator.Decimal64remainder(Decimal64 a)IEEE remainder operator.Decimal64rint()Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers.Decimal64rootN(int n)Nth root.longround()Get the closest long to instance value.Decimal64scalb(int n)Multiply the instance by a power of 2.shortshortValue()The current implementation performs casting to ashort.Decimal64signum()Compute the signum of the instance.Decimal64sin()Sine operation.Decimal64sinh()Hyperbolic sine operation.Decimal64sqrt()Square root.Decimal64subtract(double a)'-' operator.Decimal64subtract(Decimal64 a)Compute this - a.Decimal64tan()Tangent operation.Decimal64tanh()Hyperbolic tangent operation.StringtoString()The returnedStringis equal toDouble.toString(this.doubleValue())-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hipparchus.RealFieldElement
sinCos
-
-
-
-
Field Detail
-
ZERO
public static final Decimal64 ZERO
The constant value of0das aDecimal64.
-
ONE
public static final Decimal64 ONE
The constant value of1das aDecimal64.
-
NEGATIVE_INFINITY
public static final Decimal64 NEGATIVE_INFINITY
The constant value ofDouble.NEGATIVE_INFINITYas aDecimal64.
-
POSITIVE_INFINITY
public static final Decimal64 POSITIVE_INFINITY
The constant value ofDouble.POSITIVE_INFINITYas aDecimal64.
-
NAN
public static final Decimal64 NAN
The constant value ofDouble.NaNas aDecimal64.
-
-
Method Detail
-
getField
public Field<Decimal64> getField()
Get theFieldto which the instance belongs.- Specified by:
getFieldin interfaceFieldElement<Decimal64>- Returns:
Fieldto which the instance belongs
-
add
public Decimal64 add(Decimal64 a)
Compute this + a. The current implementation strictly enforcesthis.add(a).equals(new Decimal64(this.doubleValue() + a.doubleValue())).- Specified by:
addin interfaceFieldElement<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 enforcesthis.subtract(a).equals(new Decimal64(this.doubleValue() - a.doubleValue())).- Specified by:
subtractin interfaceFieldElement<Decimal64>- Parameters:
a- element to subtract- Returns:
- a new element representing this - a
-
negate
public Decimal64 negate()
Returns the additive inverse ofthiselement. The current implementation strictly enforcesthis.negate().equals(new Decimal64(-this.doubleValue())).- Specified by:
negatein interfaceFieldElement<Decimal64>- Returns:
- the opposite of
this.
-
multiply
public Decimal64 multiply(Decimal64 a)
Compute this × a. The current implementation strictly enforcesthis.multiply(a).equals(new Decimal64(this.doubleValue() * a.doubleValue())).- Specified by:
multiplyin interfaceFieldElement<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 sumn × this = ∑i=1n this. The current implementation strictly enforcesthis.multiply(n).equals(new Decimal64(n * this.doubleValue())).- Specified by:
multiplyin interfaceFieldElement<Decimal64>- Parameters:
n- Number of timesthismust be added to itself.- Returns:
- A new element representing n × this.
-
divide
public Decimal64 divide(Decimal64 a)
Compute this ÷ a. The current implementation strictly enforcesthis.divide(a).equals(new Decimal64(this.doubleValue() / a.doubleValue())).- Specified by:
dividein interfaceFieldElement<Decimal64>- Parameters:
a- element to divide by- Returns:
- a new element representing this ÷ a
-
reciprocal
public Decimal64 reciprocal()
Returns the multiplicative inverse ofthiselement. The current implementation strictly enforcesthis.reciprocal().equals(new Decimal64(1.0 / this.doubleValue())).- Specified by:
reciprocalin interfaceFieldElement<Decimal64>- Specified by:
reciprocalin interfaceRealFieldElement<Decimal64>- Returns:
- the inverse of
this.
-
byteValue
public byte byteValue()
The current implementation performs casting to abyte.
-
shortValue
public short shortValue()
The current implementation performs casting to ashort.- Overrides:
shortValuein classNumber
-
intValue
public int intValue()
The current implementation performs casting to aint.
-
longValue
public long longValue()
The current implementation performs casting to along.
-
floatValue
public float floatValue()
The current implementation performs casting to afloat.- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein classNumber
-
compareTo
public int compareTo(Decimal64 o)
The current implementation returns the same value asnew Double(this.doubleValue()).compareTo(new Double(o.doubleValue()))- Specified by:
compareToin interfaceComparable<Decimal64>- See Also:
Double.compareTo(Double)
-
hashCode
public int hashCode()
The current implementation returns the same value asnew Double(this.doubleValue()).hashCode()- Overrides:
hashCodein classObject- See Also:
Double.hashCode()
-
toString
public String toString()
The returnedStringis equal toDouble.toString(this.doubleValue())- Overrides:
toStringin classObject- See Also:
Double.toString(double)
-
isInfinite
public boolean isInfinite()
Returnstrueifthisdouble precision number is infinite (Double.POSITIVE_INFINITYorDouble.NEGATIVE_INFINITY).- Returns:
trueifthisnumber is infinite
-
isNaN
public boolean isNaN()
Returnstrueifthisdouble precision number is Not-a-Number (NaN), false otherwise.- Returns:
trueifthisisNaN
-
getReal
public double getReal()
Get the real value of the number.- Specified by:
getRealin interfaceRealFieldElement<Decimal64>- Returns:
- real value
-
add
public Decimal64 add(double a)
'+' operator.- Specified by:
addin interfaceRealFieldElement<Decimal64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this+a
-
subtract
public Decimal64 subtract(double a)
'-' operator.- Specified by:
subtractin interfaceRealFieldElement<Decimal64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this-a
-
multiply
public Decimal64 multiply(double a)
'×' operator.- Specified by:
multiplyin interfaceRealFieldElement<Decimal64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this×a
-
divide
public Decimal64 divide(double a)
'÷' operator.- Specified by:
dividein interfaceRealFieldElement<Decimal64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this÷a
-
remainder
public Decimal64 remainder(double a)
IEEE remainder operator.- Specified by:
remainderin interfaceRealFieldElement<Decimal64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a (the even integer is chosen for n if this/a is halfway between two integers)
-
remainder
public Decimal64 remainder(Decimal64 a)
IEEE remainder operator.- Specified by:
remainderin interfaceRealFieldElement<Decimal64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a (the even integer is chosen for n if this/a is halfway between two integers)
-
abs
public Decimal64 abs()
absolute value.- Specified by:
absin interfaceRealFieldElement<Decimal64>- Returns:
- abs(this)
-
ceil
public Decimal64 ceil()
Get the smallest whole number larger than instance.- Specified by:
ceilin interfaceRealFieldElement<Decimal64>- Returns:
- ceil(this)
-
floor
public Decimal64 floor()
Get the largest whole number smaller than instance.- Specified by:
floorin interfaceRealFieldElement<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:
rintin interfaceRealFieldElement<Decimal64>- Returns:
- a double number r such that r is an integer r - 0.5 ≤ this ≤ r + 0.5
-
round
public long round()
Get the closest long to instance value.- Specified by:
roundin interfaceRealFieldElement<Decimal64>- Returns:
- closest long to
RealFieldElement.getReal()
-
signum
public Decimal64 signum()
Compute the signum of the instance. The signum is -1 for negative numbers, +1 for positive numbers and 0 otherwise- Specified by:
signumin interfaceRealFieldElement<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 NaNsignargument is treated as positive.- Specified by:
copySignin interfaceRealFieldElement<Decimal64>- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
copySign
public Decimal64 copySign(double sign)
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceRealFieldElement<Decimal64>- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
scalb
public Decimal64 scalb(int n)
Multiply the instance by a power of 2.- Specified by:
scalbin interfaceRealFieldElement<Decimal64>- Parameters:
n- power of 2- Returns:
- this × 2n
-
hypot
public Decimal64 hypot(Decimal64 y)
Returns the hypotenuse of a triangle with sidesthisandy- 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:
hypotin interfaceRealFieldElement<Decimal64>- Parameters:
y- a value- Returns:
- sqrt(this2 +y2)
-
sqrt
public Decimal64 sqrt()
Square root.- Specified by:
sqrtin interfaceRealFieldElement<Decimal64>- Returns:
- square root of the instance
-
cbrt
public Decimal64 cbrt()
Cubic root.- Specified by:
cbrtin interfaceRealFieldElement<Decimal64>- Returns:
- cubic root of the instance
-
rootN
public Decimal64 rootN(int n)
Nth root.- Specified by:
rootNin interfaceRealFieldElement<Decimal64>- Parameters:
n- order of the root- Returns:
- nth root of the instance
-
pow
public Decimal64 pow(double p)
Power operation.- Specified by:
powin interfaceRealFieldElement<Decimal64>- Parameters:
p- power to apply- Returns:
- thisp
-
pow
public Decimal64 pow(int n)
Integer power operation.- Specified by:
powin interfaceRealFieldElement<Decimal64>- Parameters:
n- power to apply- Returns:
- thisn
-
pow
public Decimal64 pow(Decimal64 e)
Power operation.- Specified by:
powin interfaceRealFieldElement<Decimal64>- Parameters:
e- exponent- Returns:
- thise
-
exp
public Decimal64 exp()
Exponential.- Specified by:
expin interfaceRealFieldElement<Decimal64>- Returns:
- exponential of the instance
-
expm1
public Decimal64 expm1()
Exponential minus 1.- Specified by:
expm1in interfaceRealFieldElement<Decimal64>- Returns:
- exponential minus one of the instance
-
log
public Decimal64 log()
Natural logarithm.- Specified by:
login interfaceRealFieldElement<Decimal64>- Returns:
- logarithm of the instance
-
log1p
public Decimal64 log1p()
Shifted natural logarithm.- Specified by:
log1pin interfaceRealFieldElement<Decimal64>- Returns:
- logarithm of one plus the instance
-
log10
public Decimal64 log10()
Base 10 logarithm.- Specified by:
log10in interfaceRealFieldElement<Decimal64>- Returns:
- base 10 logarithm of the instance
-
cos
public Decimal64 cos()
Cosine operation.- Specified by:
cosin interfaceRealFieldElement<Decimal64>- Returns:
- cos(this)
-
sin
public Decimal64 sin()
Sine operation.- Specified by:
sinin interfaceRealFieldElement<Decimal64>- Returns:
- sin(this)
-
tan
public Decimal64 tan()
Tangent operation.- Specified by:
tanin interfaceRealFieldElement<Decimal64>- Returns:
- tan(this)
-
acos
public Decimal64 acos()
Arc cosine operation.- Specified by:
acosin interfaceRealFieldElement<Decimal64>- Returns:
- acos(this)
-
asin
public Decimal64 asin()
Arc sine operation.- Specified by:
asinin interfaceRealFieldElement<Decimal64>- Returns:
- asin(this)
-
atan
public Decimal64 atan()
Arc tangent operation.- Specified by:
atanin interfaceRealFieldElement<Decimal64>- Returns:
- atan(this)
-
atan2
public Decimal64 atan2(Decimal64 x)
Two arguments arc tangent operation.- Specified by:
atan2in interfaceRealFieldElement<Decimal64>- Parameters:
x- second argument of the arc tangent- Returns:
- atan2(this, x)
-
cosh
public Decimal64 cosh()
Hyperbolic cosine operation.- Specified by:
coshin interfaceRealFieldElement<Decimal64>- Returns:
- cosh(this)
-
sinh
public Decimal64 sinh()
Hyperbolic sine operation.- Specified by:
sinhin interfaceRealFieldElement<Decimal64>- Returns:
- sinh(this)
-
tanh
public Decimal64 tanh()
Hyperbolic tangent operation.- Specified by:
tanhin interfaceRealFieldElement<Decimal64>- Returns:
- tanh(this)
-
acosh
public Decimal64 acosh()
Inverse hyperbolic cosine operation.- Specified by:
acoshin interfaceRealFieldElement<Decimal64>- Returns:
- acosh(this)
-
asinh
public Decimal64 asinh()
Inverse hyperbolic sine operation.- Specified by:
asinhin interfaceRealFieldElement<Decimal64>- Returns:
- asin(this)
-
atanh
public Decimal64 atanh()
Inverse hyperbolic tangent operation.- Specified by:
atanhin interfaceRealFieldElement<Decimal64>- Returns:
- atanh(this)
-
linearCombination
public Decimal64 linearCombination(Decimal64[] a, Decimal64[] b) throws MathIllegalArgumentException
Compute a linear combination.- Specified by:
linearCombinationin interfaceRealFieldElement<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:
linearCombinationin interfaceRealFieldElement<Decimal64>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
public Decimal64 linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2)
Compute a linear combination.- Specified by:
linearCombinationin interfaceRealFieldElement<Decimal64>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second term- Returns:
- a1×b1 + a2×b2
- See Also:
RealFieldElement.linearCombination(Object, Object, Object, Object, Object, Object),RealFieldElement.linearCombination(Object, Object, Object, Object, Object, Object, Object, Object)
-
linearCombination
public Decimal64 linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2)
Compute a linear combination.- Specified by:
linearCombinationin interfaceRealFieldElement<Decimal64>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second term- Returns:
- a1×b1 + a2×b2
- See Also:
RealFieldElement.linearCombination(double, Object, double, Object, double, Object),RealFieldElement.linearCombination(double, Object, double, Object, double, Object, double, Object)
-
linearCombination
public Decimal64 linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2, Decimal64 a3, Decimal64 b3)
Compute a linear combination.- Specified by:
linearCombinationin interfaceRealFieldElement<Decimal64>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second terma3- first factor of the third termb3- second factor of the third term- Returns:
- a1×b1 + a2×b2 + a3×b3
- See Also:
RealFieldElement.linearCombination(Object, Object, Object, Object),RealFieldElement.linearCombination(Object, Object, Object, Object, Object, Object, Object, Object)
-
linearCombination
public Decimal64 linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2, double a3, Decimal64 b3)
Compute a linear combination.- Specified by:
linearCombinationin interfaceRealFieldElement<Decimal64>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second terma3- first factor of the third termb3- second factor of the third term- Returns:
- a1×b1 + a2×b2 + a3×b3
- See Also:
RealFieldElement.linearCombination(double, Object, double, Object),RealFieldElement.linearCombination(double, Object, double, Object, double, Object, double, Object)
-
linearCombination
public Decimal64 linearCombination(Decimal64 a1, Decimal64 b1, Decimal64 a2, Decimal64 b2, Decimal64 a3, Decimal64 b3, Decimal64 a4, Decimal64 b4)
Compute a linear combination.- Specified by:
linearCombinationin interfaceRealFieldElement<Decimal64>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second terma3- first factor of the third termb3- second factor of the third terma4- first factor of the fourth termb4- second factor of the fourth term- Returns:
- a1×b1 + a2×b2 + a3×b3 + a4×b4
- See Also:
RealFieldElement.linearCombination(Object, Object, Object, Object),RealFieldElement.linearCombination(Object, Object, Object, Object, Object, Object)
-
linearCombination
public Decimal64 linearCombination(double a1, Decimal64 b1, double a2, Decimal64 b2, double a3, Decimal64 b3, double a4, Decimal64 b4)
Compute a linear combination.- Specified by:
linearCombinationin interfaceRealFieldElement<Decimal64>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second terma3- first factor of the third termb3- second factor of the third terma4- first factor of the fourth termb4- second factor of the fourth term- Returns:
- a1×b1 + a2×b2 + a3×b3 + a4×b4
- See Also:
RealFieldElement.linearCombination(double, Object, double, Object),RealFieldElement.linearCombination(double, Object, double, Object, double, Object)
-
-