cc.redberry.core.number
Class Numeric
- java.lang.Object
-
- cc.redberry.core.number.Real
-
- cc.redberry.core.number.Numeric
-
- All Implemented Interfaces:
- Number<Real>, java.io.Serializable, java.lang.Comparable<Real>, org.apache.commons.math3.FieldElement<Real>
public final class Numeric extends Real implements java.io.Serializable
Implementation of floating point numbers based on Javadouble.This class implements all mathematical operations declared in
Numberas operations with doubles. So all methods return numeric numbers. As for example, 1.0 + 2 / 3 will give 1.666666 and so on. All mathematical methods works with its arguments usingNumber.doubleValue()method.- See Also:
Number,Double, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static NumericMAX_VALUEA constant holding the largest positive finite value of typedouble, (2-2-52)·21023.static NumericMIN_NORMALA constant holding the smallest positive normal value of typedouble, 2-1022.static NumericMIN_VALUEA constant holding the smallest positive nonzero value of typedouble, 2-1074.static NumericMINUS_ONEA constant holding -1 value.static NumericNaNA constant holding a Not-a-Number (NaN) value of typedouble.static NumericNEGATIVE_INFINITYA constant holding the negative infinity of typedouble.static NumericONEA constant holding 1 value.static NumericPOSITIVE_INFINITYA constant holding the positive infinity of typedouble.static NumericZEROA constant holding 0 value.
-
Constructor Summary
Constructors Constructor and Description Numeric(double value)Numeric(float value)Numeric(int value)Numeric(Number value)Constructs a newNumericinstance, whichdoublevariable is taken fromvalue.doubleValue().
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Numericabs()Numericadd(org.apache.commons.math3.fraction.BigFraction fraction)Numericadd(java.math.BigInteger bg)Numericadd(double d)Numericadd(int i)Numericadd(long l)Numericadd(Real n)java.math.BigIntegerbigIntValue()intcompareTo(Real o)Numericdivide(org.apache.commons.math3.fraction.BigFraction fraction)Numericdivide(java.math.BigInteger bg)Numericdivide(double d)Numericdivide(int i)Numericdivide(long l)Numericdivide(Real n)doubledoubleValue()booleanequals(java.lang.Object obj)floatfloatValue()NumericgetNumericValue()inthashCode()intintValue()booleanisInfinite()booleanisInteger()booleanisMinusOne()booleanisNaN()booleanisNatural()booleanisNumeric()booleanisOne()booleanisZero()longlongValue()Numericmultiply(org.apache.commons.math3.fraction.BigFraction fraction)Numericmultiply(java.math.BigInteger bg)Numericmultiply(double d)Numericmultiply(int n)Numericmultiply(long l)Numericmultiply(Real n)Numericnegate()Numericpow(java.math.BigInteger exponent)Numericpow(double exponent)Numericpow(int exponent)Numericpow(long exponent)Numericreciprocal()intsignum()Returns signum of this.Numericsubtract(org.apache.commons.math3.fraction.BigFraction fraction)Numericsubtract(java.math.BigInteger bg)Numericsubtract(double d)Numericsubtract(int i)Numericsubtract(long l)Numericsubtract(Real n)java.lang.StringtoString()
-
-
-
Field Detail
-
ZERO
public static final Numeric ZERO
A constant holding 0 value.
-
ONE
public static final Numeric ONE
A constant holding 1 value.
-
MINUS_ONE
public static final Numeric MINUS_ONE
A constant holding -1 value.
-
POSITIVE_INFINITY
public static final Numeric POSITIVE_INFINITY
A constant holding the positive infinity of typedouble. It is equal to the value returned byDouble.longBitsToDouble(0x7ff0000000000000L).- See Also:
Double.POSITIVE_INFINITY
-
NEGATIVE_INFINITY
public static final Numeric NEGATIVE_INFINITY
A constant holding the negative infinity of typedouble. It is equal to the value returned byDouble.longBitsToDouble(0xfff0000000000000L).- See Also:
Double.NEGATIVE_INFINITY
-
NaN
public static final Numeric NaN
A constant holding a Not-a-Number (NaN) value of typedouble. It is equivalent to the value returned byDouble.longBitsToDouble(0x7ff8000000000000L).- See Also:
Double.NaN
-
MAX_VALUE
public static final Numeric MAX_VALUE
A constant holding the largest positive finite value of typedouble, (2-2-52)·21023. It is equal to the hexadecimal floating-point literal0x1.fffffffffffffP+1023and also equal toDouble.longBitsToDouble(0x7fefffffffffffffL).- See Also:
Double.MAX_VALUE
-
MIN_NORMAL
public static final Numeric MIN_NORMAL
A constant holding the smallest positive normal value of typedouble, 2-1022. It is equal to the hexadecimal floating-point literal0x1.0p-1022and also equal toDouble.longBitsToDouble(0x0010000000000000L).- See Also:
Double.MIN_NORMAL
-
MIN_VALUE
public static final Numeric MIN_VALUE
A constant holding the smallest positive nonzero value of typedouble, 2-1074. It is equal to the hexadecimal floating-point literal0x0.0000000000001P-1022and also equal toDouble.longBitsToDouble(0x1L).- See Also:
Double.MIN_VALUE
-
-
Constructor Detail
-
Numeric
public Numeric(double value)
-
Numeric
public Numeric(int value)
-
Numeric
public Numeric(float value)
-
Numeric
public Numeric(Number value)
Constructs a newNumericinstance, whichdoublevariable is taken fromvalue.doubleValue(). So, this constructor makesthis.value = value.doubleValue();- Parameters:
value- the value, which double representation to be represented by theDouble.- Throws:
org.apache.commons.math3.exception.NullArgumentException- if value isnull.
-
-
Method Detail
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein interfaceNumber<Real>
-
floatValue
public float floatValue()
- Specified by:
floatValuein interfaceNumber<Real>
-
bigIntValue
public java.math.BigInteger bigIntValue()
- Specified by:
bigIntValuein interfaceNumber<Real>
-
add
public Numeric add(Real n)
- Specified by:
addin interfaceorg.apache.commons.math3.FieldElement<Real>
-
divide
public Numeric divide(Real n)
- Specified by:
dividein interfaceorg.apache.commons.math3.FieldElement<Real>
-
multiply
public Numeric multiply(int n)
- Specified by:
multiplyin interfaceorg.apache.commons.math3.FieldElement<Real>
-
multiply
public Numeric multiply(Real n)
- Specified by:
multiplyin interfaceorg.apache.commons.math3.FieldElement<Real>
-
subtract
public Numeric subtract(Real n)
- Specified by:
subtractin interfaceorg.apache.commons.math3.FieldElement<Real>
-
negate
public Numeric negate()
- Specified by:
negatein interfaceorg.apache.commons.math3.FieldElement<Real>
-
reciprocal
public Numeric reciprocal()
- Specified by:
reciprocalin interfaceorg.apache.commons.math3.FieldElement<Real>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- Returns:
- similar to
Double - See Also:
Double.hashCode()
-
isInfinite
public boolean isInfinite()
- Specified by:
isInfinitein interfaceNumber<Real>- Returns:
Double.isInfinite(value)- See Also:
Double.isInfinite(double)
-
isNaN
public boolean isNaN()
-
add
public Numeric add(org.apache.commons.math3.fraction.BigFraction fraction)
-
divide
public Numeric divide(org.apache.commons.math3.fraction.BigFraction fraction)
-
divide
public Numeric divide(java.math.BigInteger bg)
-
multiply
public Numeric multiply(org.apache.commons.math3.fraction.BigFraction fraction)
-
multiply
public Numeric multiply(java.math.BigInteger bg)
-
subtract
public Numeric subtract(org.apache.commons.math3.fraction.BigFraction fraction)
-
subtract
public Numeric subtract(java.math.BigInteger bg)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object- See Also:
Double.equals(java.lang.Object)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Double.toString()
-
getNumericValue
public Numeric getNumericValue()
- Specified by:
getNumericValuein interfaceNumber<Real>- Returns:
- this
-
compareTo
public int compareTo(Real o)
- Specified by:
compareToin interfacejava.lang.Comparable<Real>- See Also:
Double.compare(double, double)
-
isMinusOne
public boolean isMinusOne()
- Specified by:
isMinusOnein interfaceNumber<Real>
-
signum
public int signum()
Description copied from class:RealReturns signum of this.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG