Package org.hipparchus.dfp
Class DfpDec
- java.lang.Object
-
- org.hipparchus.dfp.Dfp
-
- org.hipparchus.dfp.DfpDec
-
- All Implemented Interfaces:
CalculusFieldElement<Dfp>,FieldElement<Dfp>
public class DfpDec extends Dfp
Subclass ofDfpwhich hides the radix-10000 artifacts of the superclass. This should give outward appearances of being a decimal number with DIGITS*4-3 decimal digits. This class can be subclassed to appear to be an arbitrary number of decimal digits less than DIGITS*4-3.
-
-
Constructor Summary
Constructors Modifier Constructor Description DfpDec(Dfp d)Copy constructor.protectedDfpDec(DfpField factory)Makes an instance with a value of zero.protectedDfpDec(DfpField factory, byte x)Create an instance from a byte value.protectedDfpDec(DfpField factory, byte sign, byte nans)Creates an instance with a non-finite value.protectedDfpDec(DfpField factory, double x)Create an instance from a double value.protectedDfpDec(DfpField factory, int x)Create an instance from an int value.protectedDfpDec(DfpField factory, long x)Create an instance from a long value.protectedDfpDec(DfpField factory, String s)Create an instance from a String representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intgetDecimalDigits()Get the number of decimal digits this class is going to represent.DfpnewInstance()Create an instance with a value of 0.DfpnewInstance(byte x)Create an instance from a byte value.DfpnewInstance(byte sign, byte nans)Creates an instance with a non-finite value.DfpnewInstance(double x)Create an instance corresponding to a constant real value.DfpnewInstance(int x)Create an instance from an int value.DfpnewInstance(long x)Create an instance from a long value.DfpnewInstance(String s)Create an instance from a String representation.DfpnewInstance(Dfp d)Create an instance by copying an existing one.DfpnextAfter(Dfp x)Returns the next number greater than this one in the direction of x.protected intround(int in)Round this given the next digit n using the current rounding mode.-
Methods inherited from class org.hipparchus.dfp.Dfp
abs, acos, acosh, add, align, asin, asinh, atan, atan2, atanh, ceil, classify, complement, copysign, copySign, copySign, cos, cosh, dfp2sci, dfp2string, divide, divide, dotrap, equals, exp, expm1, floor, getAddendum, getExponent, getField, getOne, getPi, getRadixDigits, getReal, getTwo, getZero, greaterThan, hashCode, hypot, intLog10, intValue, isInfinite, isNaN, isZero, lessThan, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, log, log10, log10K, log1p, multiply, multiply, negate, negativeOrNull, newInstance, positiveOrNull, pow, pow, pow, power10, power10K, reciprocal, remainder, remainder, rint, rootN, scalb, shiftLeft, shiftRight, sign, sin, sinh, sinhCosh, sqrt, square, strictlyNegative, strictlyPositive, subtract, tan, tanh, toDegrees, toDouble, toRadians, toSplitDouble, toString, trap, trunc, ulp, unequal
-
-
-
-
Constructor Detail
-
DfpDec
protected DfpDec(DfpField factory)
Makes an instance with a value of zero.- Parameters:
factory- factory linked to this instance
-
DfpDec
protected DfpDec(DfpField factory, byte x)
Create an instance from a byte value.- Parameters:
factory- factory linked to this instancex- value to convert to an instance
-
DfpDec
protected DfpDec(DfpField factory, int x)
Create an instance from an int value.- Parameters:
factory- factory linked to this instancex- value to convert to an instance
-
DfpDec
protected DfpDec(DfpField factory, long x)
Create an instance from a long value.- Parameters:
factory- factory linked to this instancex- value to convert to an instance
-
DfpDec
protected DfpDec(DfpField factory, double x)
Create an instance from a double value.- Parameters:
factory- factory linked to this instancex- value to convert to an instance
-
DfpDec
public DfpDec(Dfp d)
Copy constructor.- Parameters:
d- instance to copy
-
DfpDec
protected DfpDec(DfpField factory, String s)
Create an instance from a String representation.- Parameters:
factory- factory linked to this instances- string representation of the instance
-
DfpDec
protected DfpDec(DfpField factory, byte sign, byte nans)
Creates an instance with a non-finite value.- Parameters:
factory- factory linked to this instancesign- sign of the Dfp to createnans- code of the value, must be one ofDfp.INFINITE,Dfp.SNAN,Dfp.QNAN
-
-
Method Detail
-
newInstance
public Dfp newInstance()
Create an instance with a value of 0. Use this internally in preference to constructors to facilitate subclasses- Overrides:
newInstancein classDfp- Returns:
- a new instance with a value of 0
-
newInstance
public Dfp newInstance(byte x)
Create an instance from a byte value.- Overrides:
newInstancein classDfp- Parameters:
x- value to convert to an instance- Returns:
- a new instance with value x
-
newInstance
public Dfp newInstance(int x)
Create an instance from an int value.- Overrides:
newInstancein classDfp- Parameters:
x- value to convert to an instance- Returns:
- a new instance with value x
-
newInstance
public Dfp newInstance(long x)
Create an instance from a long value.- Overrides:
newInstancein classDfp- Parameters:
x- value to convert to an instance- Returns:
- a new instance with value x
-
newInstance
public Dfp newInstance(double x)
Create an instance corresponding to a constant real value.- Specified by:
newInstancein interfaceCalculusFieldElement<Dfp>- Overrides:
newInstancein classDfp- Parameters:
x- constant real value- Returns:
- instance corresponding to a constant real value
-
newInstance
public Dfp newInstance(Dfp d)
Create an instance by copying an existing one. Use this internally in preference to constructors to facilitate subclasses.- Overrides:
newInstancein classDfp- Parameters:
d- instance to copy- Returns:
- a new instance with the same value as d
-
newInstance
public Dfp newInstance(String s)
Create an instance from a String representation. Use this internally in preference to constructors to facilitate subclasses.- Overrides:
newInstancein classDfp- Parameters:
s- string representation of the instance- Returns:
- a new instance parsed from specified string
-
newInstance
public Dfp newInstance(byte sign, byte nans)
Creates an instance with a non-finite value.- Overrides:
newInstancein classDfp- Parameters:
sign- sign of the Dfp to createnans- code of the value, must be one ofDfp.INFINITE,Dfp.SNAN,Dfp.QNAN- Returns:
- a new instance with a non-finite value
-
getDecimalDigits
protected int getDecimalDigits()
Get the number of decimal digits this class is going to represent. Default implementation returnsDfp.getRadixDigits()*4-3. Subclasses can override this to return something less.- Returns:
- number of decimal digits this class is going to represent
-
round
protected int round(int in)
Round this given the next digit n using the current rounding mode.
-
-